@sentio/sdk 2.5.0 → 2.5.1-rc.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/aptos/codegen/codegen.js +3 -3
- package/lib/aptos/codegen/codegen.js.map +1 -1
- package/lib/aptos/move-coder.js +2 -2
- package/lib/aptos/move-coder.js.map +1 -1
- package/lib/aptos/move-types.d.ts +5 -5
- package/lib/aptos/move-types.js +15 -15
- package/lib/aptos/move-types.js.map +1 -1
- package/lib/eth/codegen/event-handler.js.map +1 -1
- package/lib/eth/codegen/functions-handler.js +4 -9
- package/lib/eth/codegen/functions-handler.js.map +1 -1
- package/lib/eth/context.js.map +1 -1
- package/lib/eth/index.d.ts +0 -1
- package/lib/eth/index.js +0 -1
- package/lib/eth/index.js.map +1 -1
- package/lib/move/abstract-codegen.d.ts +12 -12
- package/lib/move/abstract-codegen.js +30 -36
- package/lib/move/abstract-codegen.js.map +1 -1
- package/lib/move/abstract-move-coder.d.ts +4 -4
- package/lib/move/abstract-move-coder.js +3 -3
- package/lib/move/abstract-move-coder.js.map +1 -1
- package/lib/move/account.d.ts +4 -7
- package/lib/move/account.js +2 -14
- package/lib/move/account.js.map +1 -1
- package/lib/move/internal-models.d.ts +34 -0
- package/lib/move/internal-models.js +7 -0
- package/lib/move/internal-models.js.map +1 -0
- package/lib/move/ts-type.js +1 -3
- package/lib/move/ts-type.js.map +1 -1
- package/lib/move/types.d.ts +1 -0
- package/lib/move/types.js +13 -25
- package/lib/move/types.js.map +1 -1
- package/lib/sui/codegen/codegen.js +5 -5
- package/lib/sui/codegen/codegen.js.map +1 -1
- package/lib/sui/move-coder.js +2 -2
- package/lib/sui/move-coder.js.map +1 -1
- package/lib/sui/move-types.d.ts +7 -7
- package/lib/sui/move-types.js +26 -25
- package/lib/sui/move-types.js.map +1 -1
- package/lib/sui/sui-processor.js.map +1 -1
- package/lib/sui/utils.d.ts +2 -2
- package/lib/sui/utils.js.map +1 -1
- package/lib/utils/dex-price.test.js.map +1 -1
- package/lib/utils/erc20.test.js.map +1 -1
- package/package.json +10 -13
- package/src/aptos/codegen/codegen.ts +7 -7
- package/src/aptos/move-coder.ts +2 -3
- package/src/aptos/move-types.ts +20 -20
- package/src/eth/codegen/event-handler.ts +1 -1
- package/src/eth/codegen/functions-handler.ts +4 -10
- package/src/eth/context.ts +0 -1
- package/src/eth/index.ts +0 -1
- package/src/move/abstract-codegen.ts +45 -50
- package/src/move/abstract-move-coder.ts +9 -9
- package/src/move/account.ts +6 -21
- package/src/move/internal-models.ts +40 -0
- package/src/move/ts-type.ts +1 -3
- package/src/move/types.ts +13 -33
- package/src/sui/codegen/codegen.ts +8 -8
- package/src/sui/move-coder.ts +2 -2
- package/src/sui/move-types.ts +32 -31
- package/src/sui/sui-processor.ts +1 -1
- package/src/sui/utils.ts +2 -2
- package/lib/aptos/tests/aptos.test.d.ts +0 -1
- package/lib/aptos/tests/aptos.test.js.map +0 -1
- package/lib/aptos/tests/souffl3.d.ts +0 -1
- package/lib/aptos/tests/souffl3.js +0 -43
- package/lib/aptos/tests/souffl3.js.map +0 -1
- package/lib/aptos/tests/types/index.d.ts +0 -3
- package/lib/aptos/tests/types/index.js +0 -7
- package/lib/aptos/tests/types/index.js.map +0 -1
- package/lib/aptos/tests/types/reserved.d.ts +0 -340
- package/lib/aptos/tests/types/reserved.js +0 -287
- package/lib/aptos/tests/types/reserved.js.map +0 -1
- package/lib/aptos/tests/types/soffl3.d.ts +0 -801
- package/lib/aptos/tests/types/soffl3.js +0 -514
- package/lib/aptos/tests/types/soffl3.js.map +0 -1
- package/lib/aptos/tests/types/souffle.d.ts +0 -335
- package/lib/aptos/tests/types/souffle.js +0 -281
- package/lib/aptos/tests/types/souffle.js.map +0 -1
- package/lib/eth/error.d.ts +0 -1
- package/lib/eth/error.js +0 -3
- package/lib/eth/error.js.map +0 -1
- package/lib/eth/tests/account.test.d.ts +0 -1
- package/lib/eth/tests/account.test.js.map +0 -1
- package/lib/eth/tests/codegen.test.d.ts +0 -1
- package/lib/eth/tests/codegen.test.js.map +0 -1
- package/lib/eth/tests/erc20-template.test.d.ts +0 -1
- package/lib/eth/tests/erc20-template.test.js.map +0 -1
- package/lib/eth/tests/erc20.d.ts +0 -1
- package/lib/eth/tests/erc20.js +0 -52
- package/lib/eth/tests/erc20.js.map +0 -1
- package/lib/eth/tests/erc20.test.d.ts +0 -1
- package/lib/eth/tests/erc20.test.js.map +0 -1
- package/lib/eth/tests/error-capture.test.d.ts +0 -1
- package/lib/eth/tests/error-capture.test.js.map +0 -1
- package/lib/eth/tests/logger.test.d.ts +0 -1
- package/lib/eth/tests/logger.test.js.map +0 -1
- package/lib/eth/tests/types/anyswaprouter.d.ts +0 -3
- package/lib/eth/tests/types/anyswaprouter.js +0 -7
- package/lib/eth/tests/types/anyswaprouter.js.map +0 -1
- package/lib/eth/tests/types/commitmentpool.d.ts +0 -3
- package/lib/eth/tests/types/commitmentpool.js +0 -7
- package/lib/eth/tests/types/commitmentpool.js.map +0 -1
- package/lib/eth/tests/types/index.d.ts +0 -12
- package/lib/eth/tests/types/index.js +0 -16
- package/lib/eth/tests/types/index.js.map +0 -1
- package/lib/eth/tests/types/internal/AnyswapRouter.d.ts +0 -122
- package/lib/eth/tests/types/internal/AnyswapRouter.js +0 -2
- package/lib/eth/tests/types/internal/AnyswapRouter.js.map +0 -1
- package/lib/eth/tests/types/internal/CommitmentPool.d.ts +0 -176
- package/lib/eth/tests/types/internal/CommitmentPool.js +0 -2
- package/lib/eth/tests/types/internal/CommitmentPool.js.map +0 -1
- package/lib/eth/tests/types/internal/MembershipStakerV3.d.ts +0 -81
- package/lib/eth/tests/types/internal/MembershipStakerV3.js +0 -2
- package/lib/eth/tests/types/internal/MembershipStakerV3.js.map +0 -1
- package/lib/eth/tests/types/internal/Pyth.d.ts +0 -204
- package/lib/eth/tests/types/internal/Pyth.js +0 -2
- package/lib/eth/tests/types/internal/Pyth.js.map +0 -1
- package/lib/eth/tests/types/internal/Seaport.d.ts +0 -350
- package/lib/eth/tests/types/internal/Seaport.js +0 -2
- package/lib/eth/tests/types/internal/Seaport.js.map +0 -1
- package/lib/eth/tests/types/internal/TokenExchange.d.ts +0 -128
- package/lib/eth/tests/types/internal/TokenExchange.js +0 -2
- package/lib/eth/tests/types/internal/TokenExchange.js.map +0 -1
- package/lib/eth/tests/types/internal/anyswaprouter-processor.d.ts +0 -463
- package/lib/eth/tests/types/internal/anyswaprouter-processor.js +0 -425
- package/lib/eth/tests/types/internal/anyswaprouter-processor.js.map +0 -1
- package/lib/eth/tests/types/internal/anyswaprouter-test-utils.d.ts +0 -9
- package/lib/eth/tests/types/internal/anyswaprouter-test-utils.js +0 -124
- package/lib/eth/tests/types/internal/anyswaprouter-test-utils.js.map +0 -1
- package/lib/eth/tests/types/internal/commitmentpool-processor.d.ts +0 -348
- package/lib/eth/tests/types/internal/commitmentpool-processor.js +0 -607
- package/lib/eth/tests/types/internal/commitmentpool-processor.js.map +0 -1
- package/lib/eth/tests/types/internal/commitmentpool-test-utils.d.ts +0 -9
- package/lib/eth/tests/types/internal/commitmentpool-test-utils.js +0 -87
- package/lib/eth/tests/types/internal/commitmentpool-test-utils.js.map +0 -1
- package/lib/eth/tests/types/internal/common.d.ts +0 -10
- package/lib/eth/tests/types/internal/common.js +0 -8
- package/lib/eth/tests/types/internal/common.js.map +0 -1
- package/lib/eth/tests/types/internal/factories/AnyswapRouter__factory.d.ts +0 -988
- package/lib/eth/tests/types/internal/factories/AnyswapRouter__factory.js +0 -1269
- package/lib/eth/tests/types/internal/factories/AnyswapRouter__factory.js.map +0 -1
- package/lib/eth/tests/types/internal/factories/CommitmentPool__factory.d.ts +0 -792
- package/lib/eth/tests/types/internal/factories/CommitmentPool__factory.js +0 -1040
- package/lib/eth/tests/types/internal/factories/CommitmentPool__factory.js.map +0 -1
- package/lib/eth/tests/types/internal/factories/MembershipStakerV3__factory.d.ts +0 -549
- package/lib/eth/tests/types/internal/factories/MembershipStakerV3__factory.js +0 -721
- package/lib/eth/tests/types/internal/factories/MembershipStakerV3__factory.js.map +0 -1
- package/lib/eth/tests/types/internal/factories/Pyth__factory.d.ts +0 -1130
- package/lib/eth/tests/types/internal/factories/Pyth__factory.js +0 -1486
- package/lib/eth/tests/types/internal/factories/Pyth__factory.js.map +0 -1
- package/lib/eth/tests/types/internal/factories/Seaport__factory.d.ts +0 -2018
- package/lib/eth/tests/types/internal/factories/Seaport__factory.js +0 -2610
- package/lib/eth/tests/types/internal/factories/Seaport__factory.js.map +0 -1
- package/lib/eth/tests/types/internal/factories/TokenExchange__factory.d.ts +0 -651
- package/lib/eth/tests/types/internal/factories/TokenExchange__factory.js +0 -853
- package/lib/eth/tests/types/internal/factories/TokenExchange__factory.js.map +0 -1
- package/lib/eth/tests/types/internal/factories/index.d.ts +0 -6
- package/lib/eth/tests/types/internal/factories/index.js +0 -10
- package/lib/eth/tests/types/internal/factories/index.js.map +0 -1
- package/lib/eth/tests/types/internal/index.d.ts +0 -13
- package/lib/eth/tests/types/internal/index.js +0 -8
- package/lib/eth/tests/types/internal/index.js.map +0 -1
- package/lib/eth/tests/types/internal/membershipstakerv3-processor.d.ts +0 -287
- package/lib/eth/tests/types/internal/membershipstakerv3-processor.js +0 -596
- package/lib/eth/tests/types/internal/membershipstakerv3-processor.js.map +0 -1
- package/lib/eth/tests/types/internal/membershipstakerv3-test-utils.d.ts +0 -11
- package/lib/eth/tests/types/internal/membershipstakerv3-test-utils.js +0 -109
- package/lib/eth/tests/types/internal/membershipstakerv3-test-utils.js.map +0 -1
- package/lib/eth/tests/types/internal/pyth-processor.d.ts +0 -422
- package/lib/eth/tests/types/internal/pyth-processor.js +0 -890
- package/lib/eth/tests/types/internal/pyth-processor.js.map +0 -1
- package/lib/eth/tests/types/internal/pyth-test-utils.d.ts +0 -13
- package/lib/eth/tests/types/internal/pyth-test-utils.js +0 -131
- package/lib/eth/tests/types/internal/pyth-test-utils.js.map +0 -1
- package/lib/eth/tests/types/internal/seaport-processor.d.ts +0 -211
- package/lib/eth/tests/types/internal/seaport-processor.js +0 -237
- package/lib/eth/tests/types/internal/seaport-processor.js.map +0 -1
- package/lib/eth/tests/types/internal/seaport-test-utils.d.ts +0 -6
- package/lib/eth/tests/types/internal/seaport-test-utils.js +0 -61
- package/lib/eth/tests/types/internal/seaport-test-utils.js.map +0 -1
- package/lib/eth/tests/types/internal/tokenexchange-processor.d.ts +0 -334
- package/lib/eth/tests/types/internal/tokenexchange-processor.js +0 -667
- package/lib/eth/tests/types/internal/tokenexchange-processor.js.map +0 -1
- package/lib/eth/tests/types/internal/tokenexchange-test-utils.d.ts +0 -13
- package/lib/eth/tests/types/internal/tokenexchange-test-utils.js +0 -149
- package/lib/eth/tests/types/internal/tokenexchange-test-utils.js.map +0 -1
- package/lib/eth/tests/types/membershipstakerv3.d.ts +0 -3
- package/lib/eth/tests/types/membershipstakerv3.js +0 -7
- package/lib/eth/tests/types/membershipstakerv3.js.map +0 -1
- package/lib/eth/tests/types/pyth.d.ts +0 -3
- package/lib/eth/tests/types/pyth.js +0 -7
- package/lib/eth/tests/types/pyth.js.map +0 -1
- package/lib/eth/tests/types/seaport.d.ts +0 -3
- package/lib/eth/tests/types/seaport.js +0 -7
- package/lib/eth/tests/types/seaport.js.map +0 -1
- package/lib/eth/tests/types/tokenexchange.d.ts +0 -3
- package/lib/eth/tests/types/tokenexchange.js +0 -7
- package/lib/eth/tests/types/tokenexchange.js.map +0 -1
- package/lib/move/neutral-models.d.ts +0 -34
- package/lib/move/neutral-models.js +0 -7
- package/lib/move/neutral-models.js.map +0 -1
- package/lib/solana/tests/solana.test.d.ts +0 -1
- package/lib/solana/tests/solana.test.js.map +0 -1
- package/lib/solana/tests/types/basic_1.d.ts +0 -26
- package/lib/solana/tests/types/basic_1.js +0 -63
- package/lib/solana/tests/types/basic_1.js.map +0 -1
- package/lib/solana/tests/types/basic_1_processor.d.ts +0 -21
- package/lib/solana/tests/types/basic_1_processor.js +0 -35
- package/lib/solana/tests/types/basic_1_processor.js.map +0 -1
- package/lib/solana/tests/types/token_bridge.d.ts +0 -29
- package/lib/solana/tests/types/token_bridge.js +0 -938
- package/lib/solana/tests/types/token_bridge.js.map +0 -1
- package/lib/solana/tests/types/token_bridge_processor.d.ts +0 -212
- package/lib/solana/tests/types/token_bridge_processor.js +0 -134
- package/lib/solana/tests/types/token_bridge_processor.js.map +0 -1
- package/lib/solana/tests/wormhole-token-bridge.d.ts +0 -15
- package/lib/solana/tests/wormhole-token-bridge.js +0 -79
- package/lib/solana/tests/wormhole-token-bridge.js.map +0 -1
- package/lib/sui/tests/sui.test.d.ts +0 -1
- package/lib/sui/tests/sui.test.js.map +0 -1
- package/lib/sui/tests/types/index.d.ts +0 -1
- package/lib/sui/tests/types/index.js +0 -5
- package/lib/sui/tests/types/index.js.map +0 -1
- package/lib/sui/tests/types/testnet/index.d.ts +0 -1
- package/lib/sui/tests/types/testnet/index.js +0 -5
- package/lib/sui/tests/types/testnet/index.js.map +0 -1
- package/lib/sui/tests/types/testnet/swap.d.ts +0 -249
- package/lib/sui/tests/types/testnet/swap.js +0 -310
- package/lib/sui/tests/types/testnet/swap.js.map +0 -1
- package/src/aptos/tests/abis/reserved.json +0 -402
- package/src/aptos/tests/abis/soffl3.json +0 -1411
- package/src/aptos/tests/abis/souffle.json +0 -389
- package/src/aptos/tests/souffl3.ts +0 -56
- package/src/aptos/tests/types/index.ts +0 -6
- package/src/aptos/tests/types/reserved.ts +0 -766
- package/src/aptos/tests/types/soffl3.ts +0 -1528
- package/src/aptos/tests/types/souffle.ts +0 -765
- package/src/eth/error.ts +0 -4
- package/src/eth/tests/abis/eth/CommitmentPool.json +0 -1034
- package/src/eth/tests/abis/eth/MembershipStakerV3.json +0 -706
- package/src/eth/tests/abis/eth/Pyth.json +0 -1471
- package/src/eth/tests/abis/eth/Seaport.json +0 -2595
- package/src/eth/tests/abis/eth/TokenExchange.json +0 -838
- package/src/eth/tests/abis/eth/anyswapRouter.json +0 -490
- package/src/eth/tests/erc20.ts +0 -63
- package/src/eth/tests/types/anyswaprouter.ts +0 -7
- package/src/eth/tests/types/commitmentpool.ts +0 -7
- package/src/eth/tests/types/index.ts +0 -33
- package/src/eth/tests/types/internal/AnyswapRouter.ts +0 -122
- package/src/eth/tests/types/internal/CommitmentPool.ts +0 -208
- package/src/eth/tests/types/internal/MembershipStakerV3.ts +0 -108
- package/src/eth/tests/types/internal/Pyth.ts +0 -246
- package/src/eth/tests/types/internal/Seaport.ts +0 -389
- package/src/eth/tests/types/internal/TokenExchange.ts +0 -142
- package/src/eth/tests/types/internal/anyswaprouter-processor.ts +0 -1396
- package/src/eth/tests/types/internal/anyswaprouter-test-utils.ts +0 -187
- package/src/eth/tests/types/internal/commitmentpool-processor.ts +0 -1575
- package/src/eth/tests/types/internal/commitmentpool-test-utils.ts +0 -150
- package/src/eth/tests/types/internal/common.ts +0 -23
- package/src/eth/tests/types/internal/factories/AnyswapRouter__factory.ts +0 -1278
- package/src/eth/tests/types/internal/factories/CommitmentPool__factory.ts +0 -1049
- package/src/eth/tests/types/internal/factories/MembershipStakerV3__factory.ts +0 -730
- package/src/eth/tests/types/internal/factories/Pyth__factory.ts +0 -1492
- package/src/eth/tests/types/internal/factories/Seaport__factory.ts +0 -2616
- package/src/eth/tests/types/internal/factories/TokenExchange__factory.ts +0 -862
- package/src/eth/tests/types/internal/factories/index.ts +0 -9
- package/src/eth/tests/types/internal/index.ts +0 -16
- package/src/eth/tests/types/internal/membershipstakerv3-processor.ts +0 -1399
- package/src/eth/tests/types/internal/membershipstakerv3-test-utils.ts +0 -188
- package/src/eth/tests/types/internal/pyth-processor.ts +0 -2043
- package/src/eth/tests/types/internal/pyth-test-utils.ts +0 -226
- package/src/eth/tests/types/internal/seaport-processor.ts +0 -678
- package/src/eth/tests/types/internal/seaport-test-utils.ts +0 -100
- package/src/eth/tests/types/internal/tokenexchange-processor.ts +0 -1570
- package/src/eth/tests/types/internal/tokenexchange-test-utils.ts +0 -244
- package/src/eth/tests/types/membershipstakerv3.ts +0 -7
- package/src/eth/tests/types/pyth.ts +0 -7
- package/src/eth/tests/types/seaport.ts +0 -7
- package/src/eth/tests/types/tokenexchange.ts +0 -7
- package/src/move/neutral-models.ts +0 -45
- package/src/solana/tests/abis/basic_1.json +0 -62
- package/src/solana/tests/abis/token_bridge.json +0 -937
- package/src/solana/tests/types/basic_1.ts +0 -62
- package/src/solana/tests/types/basic_1_processor.ts +0 -42
- package/src/solana/tests/types/token_bridge.ts +0 -937
- package/src/solana/tests/types/token_bridge_processor.ts +0 -150
- package/src/solana/tests/wormhole-token-bridge.ts +0 -96
- package/src/sui/tests/abis/testnet/swap.json +0 -1752
- package/src/sui/tests/types/index.ts +0 -3
- package/src/sui/tests/types/testnet/index.ts +0 -4
- package/src/sui/tests/types/testnet/swap.ts +0 -698
|
@@ -1,150 +0,0 @@
|
|
|
1
|
-
import { BorshInstructionCoder, Instruction, Idl } from '@project-serum/anchor'
|
|
2
|
-
import { SolanaBaseProcessor, SolanaContext, SolanaBindOptions } from "@sentio/sdk/solana"
|
|
3
|
-
import { token_bridge_idl } from "./token_bridge.js"
|
|
4
|
-
import { PublicKey } from '@solana/web3.js'
|
|
5
|
-
|
|
6
|
-
export class TokenBridgeProcessor extends SolanaBaseProcessor {
|
|
7
|
-
static DEFAULT_OPTIONS = {
|
|
8
|
-
name: 'TokenBridge',
|
|
9
|
-
instructionCoder: new BorshInstructionCoder(token_bridge_idl as Idl)
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
static bind(options: SolanaBindOptions): TokenBridgeProcessor {
|
|
13
|
-
return new TokenBridgeProcessor( { ...TokenBridgeProcessor.DEFAULT_OPTIONS, ...options })
|
|
14
|
-
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
onInitialize(handler: (args: { wormhole: PublicKey }, accounts: { payer: string, config: string, rent: string, systemProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
18
|
-
this.onInstruction('initialize', (ins: Instruction, ctx, accounts: string[]) => {
|
|
19
|
-
const origin = ins.data as any
|
|
20
|
-
if (origin) {
|
|
21
|
-
const data = { wormhole: origin.wormhole as PublicKey }
|
|
22
|
-
const accountData = { payer: accounts[0], config: accounts[1], rent: accounts[2], systemProgram: accounts[3] }
|
|
23
|
-
handler(data, accountData, ctx)
|
|
24
|
-
}
|
|
25
|
-
})
|
|
26
|
-
return this
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
onAttestToken(handler: (args: { nonce: number }, accounts: { payer: string, config: string, mint: string, wrappedMeta: string, splMetadata: string, wormholeBridge: string, wormholeMessage: string, wormholeEmitter: string, wormholeSequence: string, wormholeFeeCollector: string, clock: string, rent: string, systemProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
30
|
-
this.onInstruction('attestToken', (ins: Instruction, ctx, accounts: string[]) => {
|
|
31
|
-
const origin = ins.data as any
|
|
32
|
-
if (origin) {
|
|
33
|
-
const data = { nonce: origin.nonce as number }
|
|
34
|
-
const accountData = { payer: accounts[0], config: accounts[1], mint: accounts[2], wrappedMeta: accounts[3], splMetadata: accounts[4], wormholeBridge: accounts[5], wormholeMessage: accounts[6], wormholeEmitter: accounts[7], wormholeSequence: accounts[8], wormholeFeeCollector: accounts[9], clock: accounts[10], rent: accounts[11], systemProgram: accounts[12], wormholeProgram: accounts[13] }
|
|
35
|
-
handler(data, accountData, ctx)
|
|
36
|
-
}
|
|
37
|
-
})
|
|
38
|
-
return this
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
onCompleteNative(handler: (args: { }, accounts: { payer: string, config: string, vaa: string, claim: string, endpoint: string, to: string, toFees: string, custody: string, mint: string, custodySigner: string, rent: string, systemProgram: string, tokenProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
42
|
-
this.onInstruction('completeNative', (ins: Instruction, ctx, accounts: string[]) => {
|
|
43
|
-
const origin = ins.data as any
|
|
44
|
-
if (origin) {
|
|
45
|
-
const data = { }
|
|
46
|
-
const accountData = { payer: accounts[0], config: accounts[1], vaa: accounts[2], claim: accounts[3], endpoint: accounts[4], to: accounts[5], toFees: accounts[6], custody: accounts[7], mint: accounts[8], custodySigner: accounts[9], rent: accounts[10], systemProgram: accounts[11], tokenProgram: accounts[12], wormholeProgram: accounts[13] }
|
|
47
|
-
handler(data, accountData, ctx)
|
|
48
|
-
}
|
|
49
|
-
})
|
|
50
|
-
return this
|
|
51
|
-
}
|
|
52
|
-
|
|
53
|
-
onCompleteWrapped(handler: (args: { }, accounts: { payer: string, config: string, vaa: string, claim: string, endpoint: string, to: string, toFees: string, mint: string, wrappedMeta: string, mintAuthority: string, rent: string, systemProgram: string, tokenProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
54
|
-
this.onInstruction('completeWrapped', (ins: Instruction, ctx, accounts: string[]) => {
|
|
55
|
-
const origin = ins.data as any
|
|
56
|
-
if (origin) {
|
|
57
|
-
const data = { }
|
|
58
|
-
const accountData = { payer: accounts[0], config: accounts[1], vaa: accounts[2], claim: accounts[3], endpoint: accounts[4], to: accounts[5], toFees: accounts[6], mint: accounts[7], wrappedMeta: accounts[8], mintAuthority: accounts[9], rent: accounts[10], systemProgram: accounts[11], tokenProgram: accounts[12], wormholeProgram: accounts[13] }
|
|
59
|
-
handler(data, accountData, ctx)
|
|
60
|
-
}
|
|
61
|
-
})
|
|
62
|
-
return this
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
onTransferWrapped(handler: (args: { nonce: number, amount: bigint, fee: bigint, targetAddress: any, targetChain: number }, accounts: { payer: string, config: string, from: string, fromOwner: string, mint: string, wrappedMeta: string, authoritySigner: string, wormholeBridge: string, wormholeMessage: string, wormholeEmitter: string, wormholeSequence: string, wormholeFeeCollector: string, clock: string, rent: string, systemProgram: string, tokenProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
66
|
-
this.onInstruction('transferWrapped', (ins: Instruction, ctx, accounts: string[]) => {
|
|
67
|
-
const origin = ins.data as any
|
|
68
|
-
if (origin) {
|
|
69
|
-
const data = { nonce: origin.nonce as number, amount: BigInt(origin.amount.toString()), fee: BigInt(origin.fee.toString()), targetAddress: origin.targetAddress as any, targetChain: origin.targetChain as number }
|
|
70
|
-
const accountData = { payer: accounts[0], config: accounts[1], from: accounts[2], fromOwner: accounts[3], mint: accounts[4], wrappedMeta: accounts[5], authoritySigner: accounts[6], wormholeBridge: accounts[7], wormholeMessage: accounts[8], wormholeEmitter: accounts[9], wormholeSequence: accounts[10], wormholeFeeCollector: accounts[11], clock: accounts[12], rent: accounts[13], systemProgram: accounts[14], tokenProgram: accounts[15], wormholeProgram: accounts[16] }
|
|
71
|
-
handler(data, accountData, ctx)
|
|
72
|
-
}
|
|
73
|
-
})
|
|
74
|
-
return this
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
onTransferNative(handler: (args: { nonce: number, amount: bigint, fee: bigint, targetAddress: any, targetChain: number }, accounts: { payer: string, config: string, from: string, mint: string, custody: string, authoritySigner: string, custodySigner: string, wormholeBridge: string, wormholeMessage: string, wormholeEmitter: string, wormholeSequence: string, wormholeFeeCollector: string, clock: string, rent: string, systemProgram: string, tokenProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
78
|
-
this.onInstruction('transferNative', (ins: Instruction, ctx, accounts: string[]) => {
|
|
79
|
-
const origin = ins.data as any
|
|
80
|
-
if (origin) {
|
|
81
|
-
const data = { nonce: origin.nonce as number, amount: BigInt(origin.amount.toString()), fee: BigInt(origin.fee.toString()), targetAddress: origin.targetAddress as any, targetChain: origin.targetChain as number }
|
|
82
|
-
const accountData = { payer: accounts[0], config: accounts[1], from: accounts[2], mint: accounts[3], custody: accounts[4], authoritySigner: accounts[5], custodySigner: accounts[6], wormholeBridge: accounts[7], wormholeMessage: accounts[8], wormholeEmitter: accounts[9], wormholeSequence: accounts[10], wormholeFeeCollector: accounts[11], clock: accounts[12], rent: accounts[13], systemProgram: accounts[14], tokenProgram: accounts[15], wormholeProgram: accounts[16] }
|
|
83
|
-
handler(data, accountData, ctx)
|
|
84
|
-
}
|
|
85
|
-
})
|
|
86
|
-
return this
|
|
87
|
-
}
|
|
88
|
-
|
|
89
|
-
onRegisterChain(handler: (args: { }, accounts: { payer: string, config: string, endpoint: string, vaa: string, claim: string, rent: string, systemProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
90
|
-
this.onInstruction('registerChain', (ins: Instruction, ctx, accounts: string[]) => {
|
|
91
|
-
const origin = ins.data as any
|
|
92
|
-
if (origin) {
|
|
93
|
-
const data = { }
|
|
94
|
-
const accountData = { payer: accounts[0], config: accounts[1], endpoint: accounts[2], vaa: accounts[3], claim: accounts[4], rent: accounts[5], systemProgram: accounts[6], wormholeProgram: accounts[7] }
|
|
95
|
-
handler(data, accountData, ctx)
|
|
96
|
-
}
|
|
97
|
-
})
|
|
98
|
-
return this
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
onCreateWrapped(handler: (args: { }, accounts: { payer: string, config: string, endpoint: string, vaa: string, claim: string, mint: string, wrappedMeta: string, splMetadata: string, mintAuthority: string, rent: string, systemProgram: string, tokenProgram: string, splMetadataProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
102
|
-
this.onInstruction('createWrapped', (ins: Instruction, ctx, accounts: string[]) => {
|
|
103
|
-
const origin = ins.data as any
|
|
104
|
-
if (origin) {
|
|
105
|
-
const data = { }
|
|
106
|
-
const accountData = { payer: accounts[0], config: accounts[1], endpoint: accounts[2], vaa: accounts[3], claim: accounts[4], mint: accounts[5], wrappedMeta: accounts[6], splMetadata: accounts[7], mintAuthority: accounts[8], rent: accounts[9], systemProgram: accounts[10], tokenProgram: accounts[11], splMetadataProgram: accounts[12], wormholeProgram: accounts[13] }
|
|
107
|
-
handler(data, accountData, ctx)
|
|
108
|
-
}
|
|
109
|
-
})
|
|
110
|
-
return this
|
|
111
|
-
}
|
|
112
|
-
|
|
113
|
-
onUpgradeContract(handler: (args: { }, accounts: { payer: string, vaa: string, claim: string, upgradeAuthority: string, spill: string, implementation: string, programData: string, tokenBridgeProgram: string, rent: string, clock: string, bpfLoaderUpgradeable: string, systemProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
114
|
-
this.onInstruction('upgradeContract', (ins: Instruction, ctx, accounts: string[]) => {
|
|
115
|
-
const origin = ins.data as any
|
|
116
|
-
if (origin) {
|
|
117
|
-
const data = { }
|
|
118
|
-
const accountData = { payer: accounts[0], vaa: accounts[1], claim: accounts[2], upgradeAuthority: accounts[3], spill: accounts[4], implementation: accounts[5], programData: accounts[6], tokenBridgeProgram: accounts[7], rent: accounts[8], clock: accounts[9], bpfLoaderUpgradeable: accounts[10], systemProgram: accounts[11] }
|
|
119
|
-
handler(data, accountData, ctx)
|
|
120
|
-
}
|
|
121
|
-
})
|
|
122
|
-
return this
|
|
123
|
-
}
|
|
124
|
-
|
|
125
|
-
onTransferWrappedWithPayload(handler: (args: { nonce: number, amount: bigint, targetAddress: any, targetChain: number, payload: any, cpiProgramId: any }, accounts: { payer: string, config: string, from: string, fromOwner: string, mint: string, wrappedMeta: string, authoritySigner: string, wormholeBridge: string, wormholeMessage: string, wormholeEmitter: string, wormholeSequence: string, wormholeFeeCollector: string, clock: string, sender: string, rent: string, systemProgram: string, tokenProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
126
|
-
this.onInstruction('transferWrappedWithPayload', (ins: Instruction, ctx, accounts: string[]) => {
|
|
127
|
-
const origin = ins.data as any
|
|
128
|
-
if (origin) {
|
|
129
|
-
const data = { nonce: origin.nonce as number, amount: BigInt(origin.amount.toString()), targetAddress: origin.targetAddress as any, targetChain: origin.targetChain as number, payload: origin.payload as any, cpiProgramId: origin.cpiProgramId as any }
|
|
130
|
-
const accountData = { payer: accounts[0], config: accounts[1], from: accounts[2], fromOwner: accounts[3], mint: accounts[4], wrappedMeta: accounts[5], authoritySigner: accounts[6], wormholeBridge: accounts[7], wormholeMessage: accounts[8], wormholeEmitter: accounts[9], wormholeSequence: accounts[10], wormholeFeeCollector: accounts[11], clock: accounts[12], sender: accounts[13], rent: accounts[14], systemProgram: accounts[15], tokenProgram: accounts[16], wormholeProgram: accounts[17] }
|
|
131
|
-
handler(data, accountData, ctx)
|
|
132
|
-
}
|
|
133
|
-
})
|
|
134
|
-
return this
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
onTransferNativeWithPayload(handler: (args: { nonce: number, amount: bigint, targetAddress: any, targetChain: number, payload: any, cpiProgramId: any }, accounts: { payer: string, config: string, from: string, mint: string, custody: string, authoritySigner: string, custodySigner: string, wormholeBridge: string, wormholeMessage: string, wormholeEmitter: string, wormholeSequence: string, wormholeFeeCollector: string, clock: string, sender: string, rent: string, systemProgram: string, tokenProgram: string, wormholeProgram: string }, ctx: SolanaContext) => void): TokenBridgeProcessor {
|
|
138
|
-
this.onInstruction('transferNativeWithPayload', (ins: Instruction, ctx, accounts: string[]) => {
|
|
139
|
-
const origin = ins.data as any
|
|
140
|
-
if (origin) {
|
|
141
|
-
const data = { nonce: origin.nonce as number, amount: BigInt(origin.amount.toString()), targetAddress: origin.targetAddress as any, targetChain: origin.targetChain as number, payload: origin.payload as any, cpiProgramId: origin.cpiProgramId as any }
|
|
142
|
-
const accountData = { payer: accounts[0], config: accounts[1], from: accounts[2], mint: accounts[3], custody: accounts[4], authoritySigner: accounts[5], custodySigner: accounts[6], wormholeBridge: accounts[7], wormholeMessage: accounts[8], wormholeEmitter: accounts[9], wormholeSequence: accounts[10], wormholeFeeCollector: accounts[11], clock: accounts[12], sender: accounts[13], rent: accounts[14], systemProgram: accounts[15], tokenProgram: accounts[16], wormholeProgram: accounts[17] }
|
|
143
|
-
handler(data, accountData, ctx)
|
|
144
|
-
}
|
|
145
|
-
})
|
|
146
|
-
return this
|
|
147
|
-
}
|
|
148
|
-
|
|
149
|
-
}
|
|
150
|
-
|
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
import { SPLTokenProcessor } from '@sentio/sdk/solana/builtin'
|
|
2
|
-
import { TokenBridgeProcessor } from './types/token_bridge_processor.js'
|
|
3
|
-
|
|
4
|
-
import { token_bridge_idl } from './types/token_bridge.js'
|
|
5
|
-
import { Idl, Instruction } from '@project-serum/anchor'
|
|
6
|
-
import bs58 from 'bs58'
|
|
7
|
-
import { camelCase, upperFirst } from 'lodash-es'
|
|
8
|
-
// @ts-ignore no type definition
|
|
9
|
-
import { Layout } from 'buffer-layout'
|
|
10
|
-
import { IdlField, IdlStateMethod } from '@project-serum/anchor/dist/cjs/idl.js'
|
|
11
|
-
import * as borsh from '@coral-xyz/borsh'
|
|
12
|
-
import { IdlCoder } from '@project-serum/anchor/dist/cjs/coder/borsh/idl.js'
|
|
13
|
-
|
|
14
|
-
// TODO this could be more general
|
|
15
|
-
class TokenBridgeDecoder {
|
|
16
|
-
private ixLayout: Map<string, Layout>
|
|
17
|
-
|
|
18
|
-
constructor(idl: Idl) {
|
|
19
|
-
this.ixLayout = TokenBridgeDecoder.parseIxLayout(idl)
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
private static parseIxLayout(idl: Idl): Map<string, Layout> {
|
|
23
|
-
const stateMethods = idl.state ? idl.state.methods : []
|
|
24
|
-
|
|
25
|
-
const ixLayouts = stateMethods
|
|
26
|
-
.map((m: IdlStateMethod): [string, Layout<unknown>] => {
|
|
27
|
-
const fieldLayouts = m.args.map((arg: IdlField) => {
|
|
28
|
-
return IdlCoder.fieldLayout(arg, Array.from([...(idl.accounts ?? []), ...(idl.types ?? [])]))
|
|
29
|
-
})
|
|
30
|
-
const name = camelCase(m.name)
|
|
31
|
-
return [name, borsh.struct(fieldLayouts, name)]
|
|
32
|
-
})
|
|
33
|
-
.concat(
|
|
34
|
-
idl.instructions.map((ix) => {
|
|
35
|
-
const fieldLayouts = ix.args.map((arg: IdlField) =>
|
|
36
|
-
IdlCoder.fieldLayout(arg, Array.from([...(idl.accounts ?? []), ...(idl.types ?? [])]))
|
|
37
|
-
)
|
|
38
|
-
const name = camelCase(ix.name)
|
|
39
|
-
return [name, borsh.struct(fieldLayouts, name)]
|
|
40
|
-
})
|
|
41
|
-
)
|
|
42
|
-
return new Map(ixLayouts)
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
public decode(ix: Buffer | string, encoding: 'hex' | 'base58' = 'hex'): Instruction | null {
|
|
46
|
-
if (typeof ix === 'string') {
|
|
47
|
-
ix = encoding === 'hex' ? Buffer.from(ix, 'hex') : Buffer.from(bs58.decode(ix))
|
|
48
|
-
}
|
|
49
|
-
const discriminator = ix.subarray(0, 1).readInt8()
|
|
50
|
-
const data = ix.subarray(1)
|
|
51
|
-
|
|
52
|
-
const name = camelCase(TokenBridgeInstruction[discriminator])
|
|
53
|
-
const layout = this.ixLayout.get(name)
|
|
54
|
-
|
|
55
|
-
if (!layout) {
|
|
56
|
-
return null
|
|
57
|
-
}
|
|
58
|
-
return { data: this.ixLayout.get(name)?.decode(data), name }
|
|
59
|
-
}
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
export enum TokenBridgeInstruction {
|
|
63
|
-
Initialize,
|
|
64
|
-
AttestToken,
|
|
65
|
-
CompleteNative,
|
|
66
|
-
CompleteWrapped,
|
|
67
|
-
TransferWrapped,
|
|
68
|
-
TransferNative,
|
|
69
|
-
RegisterChain,
|
|
70
|
-
CreateWrapped,
|
|
71
|
-
UpgradeContract,
|
|
72
|
-
CompleteNativeWithPayload,
|
|
73
|
-
CompleteWrappedWithPayload,
|
|
74
|
-
TransferWrappedWithPayload,
|
|
75
|
-
TransferNativeWithPayload,
|
|
76
|
-
}
|
|
77
|
-
|
|
78
|
-
TokenBridgeProcessor.bind({
|
|
79
|
-
address: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb',
|
|
80
|
-
instructionCoder: new TokenBridgeDecoder(token_bridge_idl as Idl),
|
|
81
|
-
}).onTransferNative((args, accounts, ctx) => {
|
|
82
|
-
ctx.meter.Counter('total_transfer_amount').add(args.amount)
|
|
83
|
-
ctx.meter.Counter(accounts.payer).add(args.amount)
|
|
84
|
-
})
|
|
85
|
-
|
|
86
|
-
SPLTokenProcessor.bind({ address: 'wormDTUJ6AWPNvk59vGQbDvGJmqbDTdgWgAqcLBCgUb', processInnerInstruction: true })
|
|
87
|
-
.onMintTo((data, ctx) => {
|
|
88
|
-
if (data.mint === '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs') {
|
|
89
|
-
ctx.meter.Counter('totalWeth_supply').add(BigInt(data.amount))
|
|
90
|
-
}
|
|
91
|
-
})
|
|
92
|
-
.onBurn((data, ctx) => {
|
|
93
|
-
if (data.mint === '7vfCXTUXx5WJV5JADk17DUJ4ksgau7utNKj4b963voxs') {
|
|
94
|
-
ctx.meter.Counter('totalWeth_supply').sub(BigInt(data.amount))
|
|
95
|
-
}
|
|
96
|
-
})
|