Skip to content

Commit

Permalink
comment out erc721
Browse files Browse the repository at this point in the history
  • Loading branch information
albertolerda committed Oct 12, 2023
1 parent 2c51d5e commit 4cb1f9d
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 17 deletions.
33 changes: 17 additions & 16 deletions pkg/ethereum/src/plugins.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import erc20Abi from '@slangroom/ethereum/erc20_abi';
//const ERC721_ABI = require('./erc721_abi.json');
//const ERC721_METADATA_ABI = require('./erc721_metadata_abi.json');

const ERC721_TRANSFER_EVENT = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';
//const ERC721_TRANSFER_EVENT = '0xddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef';

/**
* @internal
Expand Down Expand Up @@ -83,20 +83,6 @@ export const execute = async (
throw new Error('Transaction failed');
}

Check warning on line 84 in pkg/ethereum/src/plugins.ts

View check run for this annotation

Codecov / codecov/patch

pkg/ethereum/src/plugins.ts#L83-L84

Added lines #L83 - L84 were not covered by tests
}
const erc20_0 = new Map([
[EthereumRequestKind.Erc20Symbol, 'symbol()'],
[EthereumRequestKind.Erc20Decimals, 'decimals()'],
[EthereumRequestKind.Erc20Name, 'name()'],
[EthereumRequestKind.Erc20TotalSupply, 'totalSupply()'],
]);
if (erc20_0.has(kind)) {
const sc = ctx.fetch('sc') as string;
if (!web3.utils.isAddress(sc)) {
throw new Error(`Not an ethereum address ${sc}`);
}
const erc20 = new web3.eth.Contract(erc20Abi, sc);
return ctx.pass((await erc20.methods[erc20_0.get(kind) || '']?.().call()) || '');
}
/*if (kind === EthereumRequestKind.Erc20Balance) {
const sc = ctx.fetch("sc") as string;
//const address = ctx.fetch("address") as string;
Expand All @@ -107,7 +93,7 @@ export const execute = async (
console.log(erc20.methods['balanceOf']?.('ciccio'))
return ctx.pass(await erc20.methods?.["balanceOf"]?.()?.call() || "");
}*/
}
if (kind === EthereumRequestKind.Erc721Id) {
const tag = ctx.fetch('transaction_id') as string;
const receipt = await web3.eth.getTransactionReceipt(
Expand All @@ -121,6 +107,21 @@ export const execute = async (
}
return ctx.pass(parseInt(log.topics[3]?.toString() || '', 16));
}
*/
const erc20_0 = new Map([
[EthereumRequestKind.Erc20Symbol, 'symbol()'],
[EthereumRequestKind.Erc20Decimals, 'decimals()'],
[EthereumRequestKind.Erc20Name, 'name()'],
[EthereumRequestKind.Erc20TotalSupply, 'totalSupply()'],
]);
if (erc20_0.has(kind)) {
const sc = ctx.fetch('sc') as string;
if (!web3.utils.isAddress(sc)) {
throw new Error(`Not an ethereum address ${sc}`);
}

Check warning on line 121 in pkg/ethereum/src/plugins.ts

View check run for this annotation

Codecov / codecov/patch

pkg/ethereum/src/plugins.ts#L120-L121

Added lines #L120 - L121 were not covered by tests
const erc20 = new web3.eth.Contract(erc20Abi, sc);
return ctx.pass((await erc20.methods[erc20_0.get(kind) || '']?.().call()) || '');
}
return ctx.fail('Should not be here');
};

Check warning on line 126 in pkg/ethereum/src/plugins.ts

View check run for this annotation

Codecov / codecov/patch

pkg/ethereum/src/plugins.ts#L126

Added line #L126 was not covered by tests

Expand Down
2 changes: 1 addition & 1 deletion pkg/ethereum/test/e2e.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import test from 'ava';
import { Slangroom } from '@slangroom/core/slangroom';
import { ethereumPlugins } from '@slangroom/ethereum';

test.skip('Retrieve a zenroom object', async (t) => {
test('Retrieve a zenroom object', async (t) => {
const script = `
Rule caller restroom-mw
Scenario ethereum
Expand Down

0 comments on commit 4cb1f9d

Please sign in to comment.