Skip to content

Commit

Permalink
chore(ci): fix chain switching on ci
Browse files Browse the repository at this point in the history
  • Loading branch information
piotr-roslaniec committed Jul 5, 2024
1 parent 228f9c2 commit 928e5c3
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions examples/taco/nodejs/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -36,26 +36,28 @@ if (!consumerPrivateKey) {
const domain = process.env.DOMAIN || domains.TESTNET;
const ritualId = parseInt(process.env.RITUAL_ID || '0');
const provider = new ethers.providers.JsonRpcProvider(rpcProviderUrl);
const chainId = domain === domains.TESTNET ? 80002 : 137;

console.log('Domain:', domain);
console.log('Ritual ID:', ritualId);
console.log('Chain ID:', chainId);

const encryptToBytes = async (messageString: string) => {
const encryptorSigner = new ethers.Wallet(encryptorPrivateKey);
console.log(
"Encryptor signer's address:",
'Encryptor signer\'s address:',
await encryptorSigner.getAddress(),
);

const message = toBytes(messageString);
console.log(format('Encrypting message ("%s") ...', messageString));

const hasPositiveBalance = new conditions.base.rpc.RpcCondition({
chain: 80002,
chain: chainId,
method: 'eth_getBalance',
parameters: [':userAddress', 'latest'],
returnValueTest: {
comparator: '>',
comparator: '>=',
value: 0,
},
});
Expand Down Expand Up @@ -91,7 +93,7 @@ const encryptToBytes = async (messageString: string) => {
const decryptFromBytes = async (encryptedBytes: Uint8Array) => {
const consumerSigner = new ethers.Wallet(consumerPrivateKey);
console.log(
"\nConsumer signer's address:",
'\nConsumer signer\'s address:',
await consumerSigner.getAddress(),
);

Expand All @@ -107,10 +109,10 @@ const decryptFromBytes = async (encryptedBytes: Uint8Array) => {
};

const runExample = async () => {
// Make sure the provider is connected to Polygon Amoy testnet
// Make sure the provider is connected to the correct network
const network = await provider.getNetwork();
if (network.chainId !== 80002) {
console.error('Please connect to Polygon Amoy testnet');
if (network.chainId !== chainId) {
throw (`Please connect your provider to an appropriate network ${chainId}`);
}
await initialize();

Expand Down

0 comments on commit 928e5c3

Please sign in to comment.