Skip to content

Commit

Permalink
fix: contract address usage (#79)
Browse files Browse the repository at this point in the history
* fix: erc5564 contract refs

* fix: erc6538 contract addr refs
  • Loading branch information
marcomariscal authored Aug 1, 2024
1 parent bc3b403 commit 9bce106
Show file tree
Hide file tree
Showing 12 changed files with 32 additions and 41 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ console.log(

```ts
import {
ERC5564_CONTRACT,
ERC5564_CONTRACT_ADDRESS,
VALID_SCHEME_ID,
createStealthClient,
} from "@scopelift/stealth-address-sdk";
Expand All @@ -149,8 +149,8 @@ const caller = "0xYourCallingContractAddress";
const schemeId = BigInt(VALID_SCHEME_ID.SCHEME_ID_1);

// The contract address of the ERC5564Announcer on your target blockchain
// You can use the provided ERC5564_CONTRACT enum to get the singleton contract address for a valid chain ID
const ERC5564Address = ERC5564_CONTRACT.SEPOLIA; // only for Sepolia for now
// You can use the provided ERC5564_CONTRACT_ADDRESS get the singleton contract address for a valid chain ID
const ERC5564Address = ERC5564_CONTRACT_ADDRESS;

async function fetchAnnouncementsForUser() {
// Example call to getAnnouncements action on the stealth client to get all potential announcements
Expand Down
6 changes: 3 additions & 3 deletions examples/getAnnouncements/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ERC5564_CONTRACT,
ERC5564_CONTRACT_ADDRESS,
VALID_SCHEME_ID,
createStealthClient,
getAnnouncements
Expand All @@ -24,8 +24,8 @@ const stealthAddress = '0xYourStealthAddress';
const schemeId = BigInt(VALID_SCHEME_ID.SCHEME_ID_1);

// The contract address of the ERC5564Announcer on your target blockchain
// You can use the provided ERC5564_CONTRACT enum to get the singleton contract address for a valid chain ID
const ERC5564Address = ERC5564_CONTRACT.SEPOLIA; // only for Sepolia for now
// You can use the provided ERC5564_CONTRACT_ADDRESS get the singleton contract address for a valid chain ID
const ERC5564Address = ERC5564_CONTRACT_ADDRESS;

async function fetchAnnouncements() {
if (!rpcUrl) throw new Error('Missing RPC_URL environment variable');
Expand Down
6 changes: 3 additions & 3 deletions examples/getAnnouncementsForUser/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ERC5564_CONTRACT,
ERC5564_CONTRACT_ADDRESS,
VALID_SCHEME_ID,
createStealthClient
} from '@scopelift/stealth-address-sdk';
Expand All @@ -20,8 +20,8 @@ const caller = '0xYourCallingContractAddress';
const schemeId = BigInt(VALID_SCHEME_ID.SCHEME_ID_1);

// The contract address of the ERC5564Announcer on your target blockchain
// You can use the provided ERC5564_CONTRACT enum to get the singleton contract address for a valid chain ID
const ERC5564Address = ERC5564_CONTRACT.SEPOLIA; // only for Sepolia for now
// You can use the provided ERC5564_CONTRACT_ADDRESS get the singleton contract address for a valid chain ID
const ERC5564Address = ERC5564_CONTRACT_ADDRESS;

// Example keys for the user
// These don't need to be from environment variables
Expand Down
5 changes: 2 additions & 3 deletions examples/getStealthMetaAddress/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ERC6538_CONTRACT,
ERC6538_CONTRACT_ADDRESS,
VALID_SCHEME_ID,
createStealthClient,
getStealthMetaAddress
Expand All @@ -13,8 +13,7 @@ if (!rpcUrl) throw new Error('Missing RPC_URL environment variable');
// Initialize the stealth client
const stealthClient = createStealthClient({ chainId, rpcUrl });

// Example getting the singleton registry contract address for Sepolia
const ERC6538Address = ERC6538_CONTRACT.SEPOLIA;
const ERC6538Address = ERC6538_CONTRACT_ADDRESS;

// Example registrant
const registrant = '0xYourRegistrantAddress'; // can also be an ens name
Expand Down
4 changes: 2 additions & 2 deletions examples/prepareAnnounce/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sepolia } from 'viem/chains';
import 'viem/window';

import {
ERC5564_CONTRACT,
ERC5564_CONTRACT_ADDRESS,
VALID_SCHEME_ID,
createStealthClient,
generateStealthAddress
Expand Down Expand Up @@ -64,7 +64,7 @@ const Example = () => {
// Prepare the announce payload
const preparedPayload = await stealthClient.prepareAnnounce({
account,
ERC5564Address: ERC5564_CONTRACT.SEPOLIA,
ERC5564Address: ERC5564_CONTRACT_ADDRESS,
args: {
schemeId: VALID_SCHEME_ID.SCHEME_ID_1,
stealthAddress,
Expand Down
4 changes: 2 additions & 2 deletions examples/prepareRegisterKeys/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sepolia } from 'viem/chains';
import 'viem/window';

import {
ERC6538_CONTRACT,
ERC6538_CONTRACT_ADDRESS,
VALID_SCHEME_ID,
createStealthClient,
parseStealthMetaAddressURI
Expand Down Expand Up @@ -62,7 +62,7 @@ const Example = () => {
// Prepare the registerKeys payload
const preparedPayload = await stealthClient.prepareRegisterKeys({
account,
ERC6538Address: ERC6538_CONTRACT.SEPOLIA,
ERC6538Address: ERC6538_CONTRACT_ADDRESS,
schemeId,
stealthMetaAddress: stealthMetaAddressToRegister
});
Expand Down
4 changes: 2 additions & 2 deletions examples/prepareRegisterKeysOnBehalf/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { sepolia } from 'viem/chains';
import 'viem/window';

import {
ERC6538_CONTRACT,
ERC6538_CONTRACT_ADDRESS,
VALID_SCHEME_ID,
createStealthClient,
parseStealthMetaAddressURI
Expand Down Expand Up @@ -62,7 +62,7 @@ const Example = () => {
// Prepare the registerKeys payload
const preparedPayload = await stealthClient.prepareRegisterKeysOnBehalf({
account, // Your wallet address
ERC6538Address: ERC6538_CONTRACT.SEPOLIA,
ERC6538Address: ERC6538_CONTRACT_ADDRESS,
args: {
registrant: '0x', // Add the registrant address here
schemeId,
Expand Down
6 changes: 3 additions & 3 deletions examples/watchAnnouncementsForUser/index.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import {
ERC5564_CONTRACT,
ERC5564_CONTRACT_ADDRESS,
VALID_SCHEME_ID,
createStealthClient
} from '@scopelift/stealth-address-sdk';
Expand All @@ -14,8 +14,8 @@ const spendingPublicKey = '0xUserSpendingPublicKey';
const viewingPrivateKey = '0xUserViewingPrivateKey';

// The contract address of the ERC5564Announcer on your target blockchain
// You can use the provided ERC5564_CONTRACT enum to get the singleton contract address for a valid chain ID
const ERC5564Address = ERC5564_CONTRACT.SEPOLIA;
// You can use the provided ERC5564_CONTRACT_ADDRESS get the singleton contract address for a valid chain ID
const ERC5564Address = ERC5564_CONTRACT_ADDRESS;

// Initialize the stealth client with your configuration
const stealthClient = createStealthClient({ chainId, rpcUrl });
Expand Down
12 changes: 6 additions & 6 deletions src/config/contractAddresses.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
// Singleton announcer contract addresses
export enum ERC5564_CONTRACT {
SEPOLIA = '0x55649E01B5Df198D18D95b5cc5051630cfD45564'
}
// This is the same for all chains
export const ERC5564_CONTRACT_ADDRESS =
'0x55649E01B5Df198D18D95b5cc5051630cfD45564';

// Singleton registry contract addresses
export enum ERC6538_CONTRACT {
SEPOLIA = '0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538'
}
// This is the same for all chains
export const ERC6538_CONTRACT_ADDRESS =
'0x6538E6bf4B0eBd30A8Ea093027Ac2422ce5d6538';
5 changes: 4 additions & 1 deletion src/config/index.ts
Original file line number Diff line number Diff line change
@@ -1,2 +1,5 @@
export { ERC5564_CONTRACT, ERC6538_CONTRACT } from './contractAddresses';
export {
ERC5564_CONTRACT_ADDRESS,
ERC6538_CONTRACT_ADDRESS
} from './contractAddresses';
export { ERC5564_BYTECODE, ERC6538_BYTECODE } from './bytecode';
9 changes: 1 addition & 8 deletions src/scripts/deployContract.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,4 @@
import type {
ERC5564AnnouncerAbi,
ERC5564_CONTRACT,
ERC6538RegistryAbi,
ERC6538_CONTRACT
} from '..';
import type { ERC5564AnnouncerAbi, ERC6538RegistryAbi } from '..';
import setupTestWallet from '../lib/helpers/test/setupTestWallet';

/**
Expand All @@ -16,12 +11,10 @@ import setupTestWallet from '../lib/helpers/test/setupTestWallet';
* @returns {Promise<`0x${string}`>} - The address of the deployed contract
*/
const deployContract = async ({
address,
abi,
bytecode,
name
}: {
address: ERC5564_CONTRACT | ERC6538_CONTRACT;
abi: typeof ERC5564AnnouncerAbi | typeof ERC6538RegistryAbi;
bytecode: `0x${string}`;
name: string;
Expand Down
6 changes: 1 addition & 5 deletions src/scripts/index.ts
Original file line number Diff line number Diff line change
@@ -1,24 +1,20 @@
import {
ERC5564AnnouncerAbi,
ERC5564_BYTECODE,
ERC5564_CONTRACT,
ERC6538RegistryAbi,
ERC6538_BYTECODE,
ERC6538_CONTRACT
ERC6538_BYTECODE
} from '..';
import deployContract from './deployContract';

const deployAllContracts = async () => {
const { address: erc5564ContractAddress, deployBlock: erc5564DeployBlock } =
await deployContract({
address: ERC5564_CONTRACT.SEPOLIA,
abi: ERC5564AnnouncerAbi,
name: 'ERC5564',
bytecode: ERC5564_BYTECODE
});

const { address: erc6538ContractAddress } = await deployContract({
address: ERC6538_CONTRACT.SEPOLIA,
abi: ERC6538RegistryAbi,
name: 'ERC6538',
bytecode: ERC6538_BYTECODE
Expand Down

0 comments on commit 9bce106

Please sign in to comment.