Skip to content

Commit 407cf07

Browse files
Merge pull request #36 from BitGo/STLX-6658_Adapt_library_to_be_not_node_dependent
feat(smart-contracts): make the library browser friendly
2 parents 3530eaf + 3b73325 commit 407cf07

21 files changed

Lines changed: 701 additions & 265 deletions

File tree

.npmignore

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
examples/
2-
test/
3-
.eslintrc.json
1+
/eth/
2+
/src/
3+
/test/
4+
/trx/
45
.drone.yml
6+
.eslintrc.json
57
tsconfig.json
68

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,7 @@ This library is quite extensible to new chains and protocols -- if there are oth
187187
feel free to submit a PR adding them. To do so, make the following changes:
188188
- Add a new supported chain creating the directory `chainName` at the root level of the project, for example eth, trx, etc.
189189
- Add the JSON ABI to `chainName/abis` directory, named `[ProtocolName].json`.
190+
- Add the new contract the index.ts on `chainName/abis`.
190191
- Add the ProtocolName and addresses for various instances of the protocol in `chainName/config/instances.json`
191192
- For example, Compound protocol has cDAI, cUSDC, etc for eth chain.
192193
- Add the protocol to the README above

eth/abis/index.ts

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
2+
import Compound from './Compound.json';
3+
import CompoundComptroller from './CompoundComptroller.json';
4+
import DepositContract from './DepositContract.json';
5+
import DSProxy from './DSProxy.json';
6+
import DSProxyActions from './DSProxyActions.json';
7+
import DSProxyActionsDsr from './DSProxyActionsDsr.json';
8+
import DSProxyFactory from './DSProxyFactory.json';
9+
import DsrManager from './DsrManager.json';
10+
import Forwarder from './Forwarder.json';
11+
import ForwarderFactory from './ForwarderFactory.json';
12+
import SkaleAllocator from './SkaleAllocator.json';
13+
import SkaleDelegationController from './SkaleDelegationController.json';
14+
import SkaleEscrow from './SkaleEscrow.json';
15+
import SkaleDistributor from './SkaleDistributor.json';
16+
import SkaleTokenState from './SkaleTokenState.json';
17+
import SkaleValidatorService from './SkaleValidatorService.json';
18+
import StandardERC20 from './StandardERC20.json';
19+
import WalletFactory from './WalletFactory.json';
20+
import WalletSimple from './WalletSimple.json';
21+
import WrappedToken from './WrappedToken.json';
22+
import WrappedTokenController from './WrappedTokenController.json';
23+
import WrappedTokenFactory from './WrappedTokenFactory.json';
24+
import WrappedTokenMembers from './WrappedTokenMembers.json';
25+
26+
export default {
27+
Compound,
28+
CompoundComptroller,
29+
DepositContract,
30+
DSProxy,
31+
DSProxyActions,
32+
DSProxyActionsDsr,
33+
DSProxyFactory,
34+
DsrManager,
35+
Forwarder,
36+
ForwarderFactory,
37+
SkaleAllocator,
38+
SkaleDelegationController,
39+
SkaleEscrow,
40+
SkaleDistributor,
41+
SkaleTokenState,
42+
SkaleValidatorService,
43+
StandardERC20,
44+
WalletFactory,
45+
WalletSimple,
46+
WrappedToken,
47+
WrappedTokenController,
48+
WrappedTokenFactory,
49+
WrappedTokenMembers,
50+
};
51+

eth/examples/StandardERC20/transfer.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,3 +12,9 @@ console.log(`To transfer ${tokenAmount} ${tokenName} to ${recipient}:\n`);
1212
console.log(`Data: ${data}`);
1313
console.log(`Amount: ${amount} ETH`);
1414
console.log(`To: ${daiContract.address}`);
15+
16+
const decoder = getContractsFactory('eth').getDecoder();
17+
18+
const wbtcData = data.slice(2);
19+
const decoded = decoder.decode(Buffer.from(wbtcData, 'hex'));
20+
console.log(`\nTransfer decoded : \n`, decoded);

0 commit comments

Comments
 (0)