-
Notifications
You must be signed in to change notification settings - Fork 281
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(sdk-coin-opeth): add opeth tokens
- Loading branch information
1 parent
490a95d
commit 1e50329
Showing
11 changed files
with
238 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
export * from './lib'; | ||
export * from './opeth'; | ||
export * from './topeth'; | ||
export * from './opethToken'; | ||
export * from './register'; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
/** | ||
* @prettier | ||
*/ | ||
import { EthLikeTokenConfig, coins } from '@bitgo/statics'; | ||
import { BitGoBase, CoinConstructor, NamedCoinConstructor } from '@bitgo/sdk-core'; | ||
import { CoinNames, EthLikeToken } from '@bitgo/abstract-eth'; | ||
|
||
import { TransactionBuilder } from './lib'; | ||
export { EthLikeTokenConfig }; | ||
|
||
export class OpethToken extends EthLikeToken { | ||
public readonly tokenConfig: EthLikeTokenConfig; | ||
static coinNames: CoinNames = { | ||
Mainnet: 'opeth', | ||
Testnet: 'topeth', | ||
}; | ||
constructor(bitgo: BitGoBase, tokenConfig: EthLikeTokenConfig) { | ||
super(bitgo, tokenConfig, OpethToken.coinNames); | ||
} | ||
static createTokenConstructor(config: EthLikeTokenConfig): CoinConstructor { | ||
return super.createTokenConstructor(config, OpethToken.coinNames); | ||
} | ||
|
||
static createTokenConstructors(): NamedCoinConstructor[] { | ||
return super.createTokenConstructors(OpethToken.coinNames); | ||
} | ||
|
||
protected getTransactionBuilder(): TransactionBuilder { | ||
return new TransactionBuilder(coins.get(this.getBaseChain())); | ||
} | ||
|
||
getFullName(): string { | ||
return 'Opeth Token'; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import 'should'; | ||
|
||
import { TestBitGo, TestBitGoAPI } from '@bitgo/sdk-test'; | ||
import { OpethToken } from '../../src'; | ||
import { BitGoAPI } from '@bitgo/sdk-api'; | ||
|
||
describe('Opeth Token:', function () { | ||
let bitgo: TestBitGoAPI; | ||
let opethTokenCoin; | ||
const tokenName = 'topeth:terc18dp'; | ||
|
||
before(function () { | ||
bitgo = TestBitGo.decorate(BitGoAPI, { env: 'test' }); | ||
OpethToken.createTokenConstructors().forEach(({ name, coinConstructor }) => { | ||
bitgo.safeRegister(name, coinConstructor); | ||
}); | ||
bitgo.initializeTestVars(); | ||
opethTokenCoin = bitgo.coin(tokenName); | ||
}); | ||
|
||
it('should return constants', function () { | ||
opethTokenCoin.getChain().should.equal('topeth:terc18dp'); | ||
opethTokenCoin.getBaseChain().should.equal('topeth'); | ||
opethTokenCoin.getFullName().should.equal('Opeth Token'); | ||
opethTokenCoin.getBaseFactor().should.equal(1e18); | ||
opethTokenCoin.type.should.equal(tokenName); | ||
opethTokenCoin.name.should.equal('Optimism Test ERC Token 18 Decimals'); | ||
opethTokenCoin.coin.should.equal('topeth'); | ||
opethTokenCoin.network.should.equal('Testnet'); | ||
opethTokenCoin.decimalPlaces.should.equal(18); | ||
}); | ||
|
||
it('should return same token by contract address', function () { | ||
const tokencoinBycontractAddress = bitgo.coin(opethTokenCoin.tokenContractAddress); | ||
opethTokenCoin.should.deepEqual(tokencoinBycontractAddress); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters