@xswap-link/sdk 0.10.7 → 0.10.9
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/.eslintrc.json +10 -1
- package/.github/workflows/publish.yml +10 -10
- package/CHANGELOG.md +12 -0
- package/dist/index.global.js +331 -331
- package/dist/index.js +9 -9
- package/dist/index.mjs +9 -9
- package/package.json +6 -3
- package/src/components/Swap/SwapView/ConfirmationView/TxOverview/index.tsx +106 -9
- package/src/components/Swap/SwapView/SwapButton/index.tsx +11 -11
- package/src/components/TxDataCard/TxDataCardUI/index.tsx +12 -18
- package/src/components/TxDataCard/index.tsx +6 -2
- package/src/constants/index.ts +19 -2
- package/src/context/SwapProvider.tsx +7 -3
- package/src/services/api.ts +1 -0
- package/src/services/solana/jupiter/extract-swap-data.ts +6 -7
- package/src/services/svm/README.md +483 -0
- package/src/services/svm/bindings/accounts/AllowedOfframp.ts +73 -0
- package/src/services/svm/bindings/accounts/Config.ts +153 -0
- package/src/services/svm/bindings/accounts/DestChain.ts +113 -0
- package/src/services/svm/bindings/accounts/Nonce.ts +97 -0
- package/src/services/svm/bindings/accounts/index.ts +15 -0
- package/src/services/svm/bindings/accounts/tokenAdminRegistry.ts +128 -0
- package/src/services/svm/bindings/errors/anchor.ts +773 -0
- package/src/services/svm/bindings/errors/custom.ts +375 -0
- package/src/services/svm/bindings/errors/index.ts +62 -0
- package/src/services/svm/bindings/instructions/ccipSend.ts +112 -0
- package/src/services/svm/bindings/instructions/getFee.ts +73 -0
- package/src/services/svm/bindings/instructions/index.ts +4 -0
- package/src/services/svm/bindings/programId.ts +6 -0
- package/src/services/svm/bindings/types/BaseChain.ts +92 -0
- package/src/services/svm/bindings/types/BaseConfig.ts +184 -0
- package/src/services/svm/bindings/types/CodeVersion.ts +88 -0
- package/src/services/svm/bindings/types/CrossChainAmount.ts +53 -0
- package/src/services/svm/bindings/types/DestChainConfig.ts +76 -0
- package/src/services/svm/bindings/types/DestChainState.ts +76 -0
- package/src/services/svm/bindings/types/GetFeeResult.ts +72 -0
- package/src/services/svm/bindings/types/LockOrBurnInV1.ts +102 -0
- package/src/services/svm/bindings/types/LockOrBurnOutV1.ts +79 -0
- package/src/services/svm/bindings/types/RampMessageHeader.ts +94 -0
- package/src/services/svm/bindings/types/RateLimitConfig.ts +72 -0
- package/src/services/svm/bindings/types/RateLimitTokenBucket.ts +76 -0
- package/src/services/svm/bindings/types/ReleaseOrMintInV1.ts +156 -0
- package/src/services/svm/bindings/types/ReleaseOrMintOutV1.ts +53 -0
- package/src/services/svm/bindings/types/RemoteAddress.ts +61 -0
- package/src/services/svm/bindings/types/RemoteConfig.ts +86 -0
- package/src/services/svm/bindings/types/RestoreOnAction.ts +120 -0
- package/src/services/svm/bindings/types/SVM2AnyMessage.ts +128 -0
- package/src/services/svm/bindings/types/SVM2AnyRampMessage.ts +166 -0
- package/src/services/svm/bindings/types/SVM2AnyTokenTransfer.ts +118 -0
- package/src/services/svm/bindings/types/SVMTokenAmount.ts +64 -0
- package/src/services/svm/bindings/types/index.ts +78 -0
- package/src/services/svm/core/client/accounts.ts +97 -0
- package/src/services/svm/core/client/events.ts +95 -0
- package/src/services/svm/core/client/fee.ts +279 -0
- package/src/services/svm/core/client/index.ts +150 -0
- package/src/services/svm/core/client/send.ts +607 -0
- package/src/services/svm/core/client/utils.ts +131 -0
- package/src/services/svm/core/models.ts +236 -0
- package/src/services/svm/index.ts +32 -0
- package/src/services/svm/utils/conversion.ts +62 -0
- package/src/services/svm/utils/errors.ts +51 -0
- package/src/services/svm/utils/keypair.ts +19 -0
- package/src/services/svm/utils/logger.ts +171 -0
- package/src/services/svm/utils/pdas/common.ts +15 -0
- package/src/services/svm/utils/pdas/feeQuoter.ts +68 -0
- package/src/services/svm/utils/pdas/index.ts +12 -0
- package/src/services/svm/utils/pdas/receiver.ts +58 -0
- package/src/services/svm/utils/pdas/rmnRemote.ts +23 -0
- package/src/services/svm/utils/pdas/router.ts +328 -0
- package/src/services/svm/utils/pdas/tokenpool.ts +161 -0
- package/src/services/svm/utils/transaction.ts +132 -0
- package/src/utils/validation.ts +7 -3
- package/tsconfig.json +2 -1
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
|
|
6
|
+
export interface BaseChainFields {
|
|
7
|
+
remote: types.RemoteConfigFields
|
|
8
|
+
inboundRateLimit: types.RateLimitTokenBucketFields
|
|
9
|
+
outboundRateLimit: types.RateLimitTokenBucketFields
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface BaseChainJSON {
|
|
13
|
+
remote: types.RemoteConfigJSON
|
|
14
|
+
inboundRateLimit: types.RateLimitTokenBucketJSON
|
|
15
|
+
outboundRateLimit: types.RateLimitTokenBucketJSON
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class BaseChain {
|
|
19
|
+
readonly remote: types.RemoteConfig
|
|
20
|
+
readonly inboundRateLimit: types.RateLimitTokenBucket
|
|
21
|
+
readonly outboundRateLimit: types.RateLimitTokenBucket
|
|
22
|
+
|
|
23
|
+
constructor(fields: BaseChainFields) {
|
|
24
|
+
this.remote = new types.RemoteConfig({ ...fields.remote })
|
|
25
|
+
this.inboundRateLimit = new types.RateLimitTokenBucket({
|
|
26
|
+
...fields.inboundRateLimit,
|
|
27
|
+
})
|
|
28
|
+
this.outboundRateLimit = new types.RateLimitTokenBucket({
|
|
29
|
+
...fields.outboundRateLimit,
|
|
30
|
+
})
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
static layout(property?: string) {
|
|
34
|
+
return borsh.struct(
|
|
35
|
+
[
|
|
36
|
+
types.RemoteConfig.layout("remote"),
|
|
37
|
+
types.RateLimitTokenBucket.layout("inboundRateLimit"),
|
|
38
|
+
types.RateLimitTokenBucket.layout("outboundRateLimit"),
|
|
39
|
+
],
|
|
40
|
+
property
|
|
41
|
+
)
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
45
|
+
static fromDecoded(obj: any) {
|
|
46
|
+
return new BaseChain({
|
|
47
|
+
remote: types.RemoteConfig.fromDecoded(obj.remote),
|
|
48
|
+
inboundRateLimit: types.RateLimitTokenBucket.fromDecoded(
|
|
49
|
+
obj.inboundRateLimit
|
|
50
|
+
),
|
|
51
|
+
outboundRateLimit: types.RateLimitTokenBucket.fromDecoded(
|
|
52
|
+
obj.outboundRateLimit
|
|
53
|
+
),
|
|
54
|
+
})
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
static toEncodable(fields: BaseChainFields) {
|
|
58
|
+
return {
|
|
59
|
+
remote: types.RemoteConfig.toEncodable(fields.remote),
|
|
60
|
+
inboundRateLimit: types.RateLimitTokenBucket.toEncodable(
|
|
61
|
+
fields.inboundRateLimit
|
|
62
|
+
),
|
|
63
|
+
outboundRateLimit: types.RateLimitTokenBucket.toEncodable(
|
|
64
|
+
fields.outboundRateLimit
|
|
65
|
+
),
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toJSON(): BaseChainJSON {
|
|
70
|
+
return {
|
|
71
|
+
remote: this.remote.toJSON(),
|
|
72
|
+
inboundRateLimit: this.inboundRateLimit.toJSON(),
|
|
73
|
+
outboundRateLimit: this.outboundRateLimit.toJSON(),
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static fromJSON(obj: BaseChainJSON): BaseChain {
|
|
78
|
+
return new BaseChain({
|
|
79
|
+
remote: types.RemoteConfig.fromJSON(obj.remote),
|
|
80
|
+
inboundRateLimit: types.RateLimitTokenBucket.fromJSON(
|
|
81
|
+
obj.inboundRateLimit
|
|
82
|
+
),
|
|
83
|
+
outboundRateLimit: types.RateLimitTokenBucket.fromJSON(
|
|
84
|
+
obj.outboundRateLimit
|
|
85
|
+
),
|
|
86
|
+
})
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
toEncodable() {
|
|
90
|
+
return BaseChain.toEncodable(this)
|
|
91
|
+
}
|
|
92
|
+
}
|
|
@@ -0,0 +1,184 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
|
|
6
|
+
export interface BaseConfigFields {
|
|
7
|
+
tokenProgram: PublicKey
|
|
8
|
+
mint: PublicKey
|
|
9
|
+
decimals: number
|
|
10
|
+
poolSigner: PublicKey
|
|
11
|
+
poolTokenAccount: PublicKey
|
|
12
|
+
owner: PublicKey
|
|
13
|
+
proposedOwner: PublicKey
|
|
14
|
+
rateLimitAdmin: PublicKey
|
|
15
|
+
routerOnrampAuthority: PublicKey
|
|
16
|
+
router: PublicKey
|
|
17
|
+
rebalancer: PublicKey
|
|
18
|
+
canAcceptLiquidity: boolean
|
|
19
|
+
listEnabled: boolean
|
|
20
|
+
allowList: Array<PublicKey>
|
|
21
|
+
rmnRemote: PublicKey
|
|
22
|
+
}
|
|
23
|
+
|
|
24
|
+
export interface BaseConfigJSON {
|
|
25
|
+
tokenProgram: string
|
|
26
|
+
mint: string
|
|
27
|
+
decimals: number
|
|
28
|
+
poolSigner: string
|
|
29
|
+
poolTokenAccount: string
|
|
30
|
+
owner: string
|
|
31
|
+
proposedOwner: string
|
|
32
|
+
rateLimitAdmin: string
|
|
33
|
+
routerOnrampAuthority: string
|
|
34
|
+
router: string
|
|
35
|
+
rebalancer: string
|
|
36
|
+
canAcceptLiquidity: boolean
|
|
37
|
+
listEnabled: boolean
|
|
38
|
+
allowList: Array<string>
|
|
39
|
+
rmnRemote: string
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export class BaseConfig {
|
|
43
|
+
readonly tokenProgram: PublicKey
|
|
44
|
+
readonly mint: PublicKey
|
|
45
|
+
readonly decimals: number
|
|
46
|
+
readonly poolSigner: PublicKey
|
|
47
|
+
readonly poolTokenAccount: PublicKey
|
|
48
|
+
readonly owner: PublicKey
|
|
49
|
+
readonly proposedOwner: PublicKey
|
|
50
|
+
readonly rateLimitAdmin: PublicKey
|
|
51
|
+
readonly routerOnrampAuthority: PublicKey
|
|
52
|
+
readonly router: PublicKey
|
|
53
|
+
readonly rebalancer: PublicKey
|
|
54
|
+
readonly canAcceptLiquidity: boolean
|
|
55
|
+
readonly listEnabled: boolean
|
|
56
|
+
readonly allowList: Array<PublicKey>
|
|
57
|
+
readonly rmnRemote: PublicKey
|
|
58
|
+
|
|
59
|
+
constructor(fields: BaseConfigFields) {
|
|
60
|
+
this.tokenProgram = fields.tokenProgram
|
|
61
|
+
this.mint = fields.mint
|
|
62
|
+
this.decimals = fields.decimals
|
|
63
|
+
this.poolSigner = fields.poolSigner
|
|
64
|
+
this.poolTokenAccount = fields.poolTokenAccount
|
|
65
|
+
this.owner = fields.owner
|
|
66
|
+
this.proposedOwner = fields.proposedOwner
|
|
67
|
+
this.rateLimitAdmin = fields.rateLimitAdmin
|
|
68
|
+
this.routerOnrampAuthority = fields.routerOnrampAuthority
|
|
69
|
+
this.router = fields.router
|
|
70
|
+
this.rebalancer = fields.rebalancer
|
|
71
|
+
this.canAcceptLiquidity = fields.canAcceptLiquidity
|
|
72
|
+
this.listEnabled = fields.listEnabled
|
|
73
|
+
this.allowList = fields.allowList
|
|
74
|
+
this.rmnRemote = fields.rmnRemote
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
static layout(property?: string) {
|
|
78
|
+
return borsh.struct(
|
|
79
|
+
[
|
|
80
|
+
borsh.publicKey("tokenProgram"),
|
|
81
|
+
borsh.publicKey("mint"),
|
|
82
|
+
borsh.u8("decimals"),
|
|
83
|
+
borsh.publicKey("poolSigner"),
|
|
84
|
+
borsh.publicKey("poolTokenAccount"),
|
|
85
|
+
borsh.publicKey("owner"),
|
|
86
|
+
borsh.publicKey("proposedOwner"),
|
|
87
|
+
borsh.publicKey("rateLimitAdmin"),
|
|
88
|
+
borsh.publicKey("routerOnrampAuthority"),
|
|
89
|
+
borsh.publicKey("router"),
|
|
90
|
+
borsh.publicKey("rebalancer"),
|
|
91
|
+
borsh.bool("canAcceptLiquidity"),
|
|
92
|
+
borsh.bool("listEnabled"),
|
|
93
|
+
borsh.vec(borsh.publicKey(), "allowList"),
|
|
94
|
+
borsh.publicKey("rmnRemote"),
|
|
95
|
+
],
|
|
96
|
+
property
|
|
97
|
+
)
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
101
|
+
static fromDecoded(obj: any) {
|
|
102
|
+
return new BaseConfig({
|
|
103
|
+
tokenProgram: obj.tokenProgram,
|
|
104
|
+
mint: obj.mint,
|
|
105
|
+
decimals: obj.decimals,
|
|
106
|
+
poolSigner: obj.poolSigner,
|
|
107
|
+
poolTokenAccount: obj.poolTokenAccount,
|
|
108
|
+
owner: obj.owner,
|
|
109
|
+
proposedOwner: obj.proposedOwner,
|
|
110
|
+
rateLimitAdmin: obj.rateLimitAdmin,
|
|
111
|
+
routerOnrampAuthority: obj.routerOnrampAuthority,
|
|
112
|
+
router: obj.router,
|
|
113
|
+
rebalancer: obj.rebalancer,
|
|
114
|
+
canAcceptLiquidity: obj.canAcceptLiquidity,
|
|
115
|
+
listEnabled: obj.listEnabled,
|
|
116
|
+
allowList: obj.allowList,
|
|
117
|
+
rmnRemote: obj.rmnRemote,
|
|
118
|
+
})
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
static toEncodable(fields: BaseConfigFields) {
|
|
122
|
+
return {
|
|
123
|
+
tokenProgram: fields.tokenProgram,
|
|
124
|
+
mint: fields.mint,
|
|
125
|
+
decimals: fields.decimals,
|
|
126
|
+
poolSigner: fields.poolSigner,
|
|
127
|
+
poolTokenAccount: fields.poolTokenAccount,
|
|
128
|
+
owner: fields.owner,
|
|
129
|
+
proposedOwner: fields.proposedOwner,
|
|
130
|
+
rateLimitAdmin: fields.rateLimitAdmin,
|
|
131
|
+
routerOnrampAuthority: fields.routerOnrampAuthority,
|
|
132
|
+
router: fields.router,
|
|
133
|
+
rebalancer: fields.rebalancer,
|
|
134
|
+
canAcceptLiquidity: fields.canAcceptLiquidity,
|
|
135
|
+
listEnabled: fields.listEnabled,
|
|
136
|
+
allowList: fields.allowList,
|
|
137
|
+
rmnRemote: fields.rmnRemote,
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
|
|
141
|
+
toJSON(): BaseConfigJSON {
|
|
142
|
+
return {
|
|
143
|
+
tokenProgram: this.tokenProgram.toString(),
|
|
144
|
+
mint: this.mint.toString(),
|
|
145
|
+
decimals: this.decimals,
|
|
146
|
+
poolSigner: this.poolSigner.toString(),
|
|
147
|
+
poolTokenAccount: this.poolTokenAccount.toString(),
|
|
148
|
+
owner: this.owner.toString(),
|
|
149
|
+
proposedOwner: this.proposedOwner.toString(),
|
|
150
|
+
rateLimitAdmin: this.rateLimitAdmin.toString(),
|
|
151
|
+
routerOnrampAuthority: this.routerOnrampAuthority.toString(),
|
|
152
|
+
router: this.router.toString(),
|
|
153
|
+
rebalancer: this.rebalancer.toString(),
|
|
154
|
+
canAcceptLiquidity: this.canAcceptLiquidity,
|
|
155
|
+
listEnabled: this.listEnabled,
|
|
156
|
+
allowList: this.allowList.map((item) => item.toString()),
|
|
157
|
+
rmnRemote: this.rmnRemote.toString(),
|
|
158
|
+
}
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
static fromJSON(obj: BaseConfigJSON): BaseConfig {
|
|
162
|
+
return new BaseConfig({
|
|
163
|
+
tokenProgram: new PublicKey(obj.tokenProgram),
|
|
164
|
+
mint: new PublicKey(obj.mint),
|
|
165
|
+
decimals: obj.decimals,
|
|
166
|
+
poolSigner: new PublicKey(obj.poolSigner),
|
|
167
|
+
poolTokenAccount: new PublicKey(obj.poolTokenAccount),
|
|
168
|
+
owner: new PublicKey(obj.owner),
|
|
169
|
+
proposedOwner: new PublicKey(obj.proposedOwner),
|
|
170
|
+
rateLimitAdmin: new PublicKey(obj.rateLimitAdmin),
|
|
171
|
+
routerOnrampAuthority: new PublicKey(obj.routerOnrampAuthority),
|
|
172
|
+
router: new PublicKey(obj.router),
|
|
173
|
+
rebalancer: new PublicKey(obj.rebalancer),
|
|
174
|
+
canAcceptLiquidity: obj.canAcceptLiquidity,
|
|
175
|
+
listEnabled: obj.listEnabled,
|
|
176
|
+
allowList: obj.allowList.map((item) => new PublicKey(item)),
|
|
177
|
+
rmnRemote: new PublicKey(obj.rmnRemote),
|
|
178
|
+
})
|
|
179
|
+
}
|
|
180
|
+
|
|
181
|
+
toEncodable() {
|
|
182
|
+
return BaseConfig.toEncodable(this)
|
|
183
|
+
}
|
|
184
|
+
}
|
|
@@ -0,0 +1,88 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
|
|
6
|
+
export interface DefaultJSON {
|
|
7
|
+
kind: "Default"
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export class Default {
|
|
11
|
+
static readonly discriminator = 0
|
|
12
|
+
static readonly kind = "Default"
|
|
13
|
+
readonly discriminator = 0
|
|
14
|
+
readonly kind = "Default"
|
|
15
|
+
|
|
16
|
+
toJSON(): DefaultJSON {
|
|
17
|
+
return {
|
|
18
|
+
kind: "Default",
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
toEncodable() {
|
|
23
|
+
return {
|
|
24
|
+
Default: {},
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export interface V1JSON {
|
|
30
|
+
kind: "V1"
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
export class V1 {
|
|
34
|
+
static readonly discriminator = 1
|
|
35
|
+
static readonly kind = "V1"
|
|
36
|
+
readonly discriminator = 1
|
|
37
|
+
readonly kind = "V1"
|
|
38
|
+
|
|
39
|
+
toJSON(): V1JSON {
|
|
40
|
+
return {
|
|
41
|
+
kind: "V1",
|
|
42
|
+
}
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
toEncodable() {
|
|
46
|
+
return {
|
|
47
|
+
V1: {},
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
53
|
+
export function fromDecoded(obj: any): types.CodeVersionKind {
|
|
54
|
+
if (typeof obj !== "object") {
|
|
55
|
+
throw new Error("Invalid enum object")
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
if ("Default" in obj) {
|
|
59
|
+
return new Default()
|
|
60
|
+
}
|
|
61
|
+
if ("V1" in obj) {
|
|
62
|
+
return new V1()
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
throw new Error("Invalid enum object")
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function fromJSON(obj: types.CodeVersionJSON): types.CodeVersionKind {
|
|
69
|
+
switch (obj.kind) {
|
|
70
|
+
case "Default": {
|
|
71
|
+
return new Default()
|
|
72
|
+
}
|
|
73
|
+
case "V1": {
|
|
74
|
+
return new V1()
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
|
|
79
|
+
export function layout(property?: string) {
|
|
80
|
+
const ret = borsh.rustEnum([
|
|
81
|
+
borsh.struct([], "Default"),
|
|
82
|
+
borsh.struct([], "V1"),
|
|
83
|
+
])
|
|
84
|
+
if (property !== undefined) {
|
|
85
|
+
return ret.replicate(property)
|
|
86
|
+
}
|
|
87
|
+
return ret
|
|
88
|
+
}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
|
|
6
|
+
export interface CrossChainAmountFields {
|
|
7
|
+
leBytes: Array<number>
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface CrossChainAmountJSON {
|
|
11
|
+
leBytes: Array<number>
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export class CrossChainAmount {
|
|
15
|
+
readonly leBytes: Array<number>
|
|
16
|
+
|
|
17
|
+
constructor(fields: CrossChainAmountFields) {
|
|
18
|
+
this.leBytes = fields.leBytes
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
static layout(property?: string) {
|
|
22
|
+
return borsh.struct([borsh.array(borsh.u8(), 32, "leBytes")], property)
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
26
|
+
static fromDecoded(obj: any) {
|
|
27
|
+
return new CrossChainAmount({
|
|
28
|
+
leBytes: obj.leBytes,
|
|
29
|
+
})
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
static toEncodable(fields: CrossChainAmountFields) {
|
|
33
|
+
return {
|
|
34
|
+
leBytes: fields.leBytes,
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
toJSON(): CrossChainAmountJSON {
|
|
39
|
+
return {
|
|
40
|
+
leBytes: this.leBytes,
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
static fromJSON(obj: CrossChainAmountJSON): CrossChainAmount {
|
|
45
|
+
return new CrossChainAmount({
|
|
46
|
+
leBytes: obj.leBytes,
|
|
47
|
+
})
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
toEncodable() {
|
|
51
|
+
return CrossChainAmount.toEncodable(this)
|
|
52
|
+
}
|
|
53
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
|
|
6
|
+
export interface DestChainConfigFields {
|
|
7
|
+
laneCodeVersion: types.CodeVersionKind
|
|
8
|
+
allowedSenders: Array<PublicKey>
|
|
9
|
+
allowListEnabled: boolean
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DestChainConfigJSON {
|
|
13
|
+
laneCodeVersion: types.CodeVersionJSON
|
|
14
|
+
allowedSenders: Array<string>
|
|
15
|
+
allowListEnabled: boolean
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class DestChainConfig {
|
|
19
|
+
readonly laneCodeVersion: types.CodeVersionKind
|
|
20
|
+
readonly allowedSenders: Array<PublicKey>
|
|
21
|
+
readonly allowListEnabled: boolean
|
|
22
|
+
|
|
23
|
+
constructor(fields: DestChainConfigFields) {
|
|
24
|
+
this.laneCodeVersion = fields.laneCodeVersion
|
|
25
|
+
this.allowedSenders = fields.allowedSenders
|
|
26
|
+
this.allowListEnabled = fields.allowListEnabled
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static layout(property?: string) {
|
|
30
|
+
return borsh.struct(
|
|
31
|
+
[
|
|
32
|
+
types.CodeVersion.layout("laneCodeVersion"),
|
|
33
|
+
borsh.vec(borsh.publicKey(), "allowedSenders"),
|
|
34
|
+
borsh.bool("allowListEnabled"),
|
|
35
|
+
],
|
|
36
|
+
property
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
static fromDecoded(obj: any) {
|
|
42
|
+
return new DestChainConfig({
|
|
43
|
+
laneCodeVersion: types.CodeVersion.fromDecoded(obj.laneCodeVersion),
|
|
44
|
+
allowedSenders: obj.allowedSenders,
|
|
45
|
+
allowListEnabled: obj.allowListEnabled,
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static toEncodable(fields: DestChainConfigFields) {
|
|
50
|
+
return {
|
|
51
|
+
laneCodeVersion: fields.laneCodeVersion.toEncodable(),
|
|
52
|
+
allowedSenders: fields.allowedSenders,
|
|
53
|
+
allowListEnabled: fields.allowListEnabled,
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
toJSON(): DestChainConfigJSON {
|
|
58
|
+
return {
|
|
59
|
+
laneCodeVersion: this.laneCodeVersion.toJSON(),
|
|
60
|
+
allowedSenders: this.allowedSenders.map((item) => item.toString()),
|
|
61
|
+
allowListEnabled: this.allowListEnabled,
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static fromJSON(obj: DestChainConfigJSON): DestChainConfig {
|
|
66
|
+
return new DestChainConfig({
|
|
67
|
+
laneCodeVersion: types.CodeVersion.fromJSON(obj.laneCodeVersion),
|
|
68
|
+
allowedSenders: obj.allowedSenders.map((item) => new PublicKey(item)),
|
|
69
|
+
allowListEnabled: obj.allowListEnabled,
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
toEncodable() {
|
|
74
|
+
return DestChainConfig.toEncodable(this)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
|
|
6
|
+
export interface DestChainStateFields {
|
|
7
|
+
sequenceNumber: BN
|
|
8
|
+
sequenceNumberToRestore: BN
|
|
9
|
+
restoreOnAction: types.RestoreOnActionKind
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface DestChainStateJSON {
|
|
13
|
+
sequenceNumber: string
|
|
14
|
+
sequenceNumberToRestore: string
|
|
15
|
+
restoreOnAction: types.RestoreOnActionJSON
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class DestChainState {
|
|
19
|
+
readonly sequenceNumber: BN
|
|
20
|
+
readonly sequenceNumberToRestore: BN
|
|
21
|
+
readonly restoreOnAction: types.RestoreOnActionKind
|
|
22
|
+
|
|
23
|
+
constructor(fields: DestChainStateFields) {
|
|
24
|
+
this.sequenceNumber = fields.sequenceNumber
|
|
25
|
+
this.sequenceNumberToRestore = fields.sequenceNumberToRestore
|
|
26
|
+
this.restoreOnAction = fields.restoreOnAction
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static layout(property?: string) {
|
|
30
|
+
return borsh.struct(
|
|
31
|
+
[
|
|
32
|
+
borsh.u64("sequenceNumber"),
|
|
33
|
+
borsh.u64("sequenceNumberToRestore"),
|
|
34
|
+
types.RestoreOnAction.layout("restoreOnAction"),
|
|
35
|
+
],
|
|
36
|
+
property
|
|
37
|
+
)
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
41
|
+
static fromDecoded(obj: any) {
|
|
42
|
+
return new DestChainState({
|
|
43
|
+
sequenceNumber: obj.sequenceNumber,
|
|
44
|
+
sequenceNumberToRestore: obj.sequenceNumberToRestore,
|
|
45
|
+
restoreOnAction: types.RestoreOnAction.fromDecoded(obj.restoreOnAction),
|
|
46
|
+
})
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
static toEncodable(fields: DestChainStateFields) {
|
|
50
|
+
return {
|
|
51
|
+
sequenceNumber: fields.sequenceNumber,
|
|
52
|
+
sequenceNumberToRestore: fields.sequenceNumberToRestore,
|
|
53
|
+
restoreOnAction: fields.restoreOnAction.toEncodable(),
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
toJSON(): DestChainStateJSON {
|
|
58
|
+
return {
|
|
59
|
+
sequenceNumber: this.sequenceNumber.toString(),
|
|
60
|
+
sequenceNumberToRestore: this.sequenceNumberToRestore.toString(),
|
|
61
|
+
restoreOnAction: this.restoreOnAction.toJSON(),
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
static fromJSON(obj: DestChainStateJSON): DestChainState {
|
|
66
|
+
return new DestChainState({
|
|
67
|
+
sequenceNumber: new BN(obj.sequenceNumber),
|
|
68
|
+
sequenceNumberToRestore: new BN(obj.sequenceNumberToRestore),
|
|
69
|
+
restoreOnAction: types.RestoreOnAction.fromJSON(obj.restoreOnAction),
|
|
70
|
+
})
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
toEncodable() {
|
|
74
|
+
return DestChainState.toEncodable(this)
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,72 @@
|
|
|
1
|
+
import { PublicKey } from "@solana/web3.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
2
|
+
import BN from "bn.js" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
3
|
+
import * as types from "../types" // eslint-disable-line @typescript-eslint/no-unused-vars
|
|
4
|
+
import * as borsh from "@coral-xyz/borsh"
|
|
5
|
+
|
|
6
|
+
export interface GetFeeResultFields {
|
|
7
|
+
amount: BN
|
|
8
|
+
juels: BN
|
|
9
|
+
token: PublicKey
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
export interface GetFeeResultJSON {
|
|
13
|
+
amount: string
|
|
14
|
+
juels: string
|
|
15
|
+
token: string
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
export class GetFeeResult {
|
|
19
|
+
readonly amount: BN
|
|
20
|
+
readonly juels: BN
|
|
21
|
+
readonly token: PublicKey
|
|
22
|
+
|
|
23
|
+
constructor(fields: GetFeeResultFields) {
|
|
24
|
+
this.amount = fields.amount
|
|
25
|
+
this.juels = fields.juels
|
|
26
|
+
this.token = fields.token
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static layout(property?: string) {
|
|
30
|
+
return borsh.struct(
|
|
31
|
+
[borsh.u64("amount"), borsh.u128("juels"), borsh.publicKey("token")],
|
|
32
|
+
property
|
|
33
|
+
)
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
37
|
+
static fromDecoded(obj: any) {
|
|
38
|
+
return new GetFeeResult({
|
|
39
|
+
amount: obj.amount,
|
|
40
|
+
juels: obj.juels,
|
|
41
|
+
token: obj.token,
|
|
42
|
+
})
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
static toEncodable(fields: GetFeeResultFields) {
|
|
46
|
+
return {
|
|
47
|
+
amount: fields.amount,
|
|
48
|
+
juels: fields.juels,
|
|
49
|
+
token: fields.token,
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
toJSON(): GetFeeResultJSON {
|
|
54
|
+
return {
|
|
55
|
+
amount: this.amount.toString(),
|
|
56
|
+
juels: this.juels.toString(),
|
|
57
|
+
token: this.token.toString(),
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
static fromJSON(obj: GetFeeResultJSON): GetFeeResult {
|
|
62
|
+
return new GetFeeResult({
|
|
63
|
+
amount: new BN(obj.amount),
|
|
64
|
+
juels: new BN(obj.juels),
|
|
65
|
+
token: new PublicKey(obj.token),
|
|
66
|
+
})
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
toEncodable() {
|
|
70
|
+
return GetFeeResult.toEncodable(this)
|
|
71
|
+
}
|
|
72
|
+
}
|