@xswap-link/sdk 0.10.8 → 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.
Files changed (69) hide show
  1. package/.eslintrc.json +10 -1
  2. package/CHANGELOG.md +6 -0
  3. package/dist/index.global.js +331 -331
  4. package/dist/index.js +9 -9
  5. package/dist/index.mjs +9 -9
  6. package/package.json +6 -3
  7. package/src/components/Swap/SwapView/ConfirmationView/TxOverview/index.tsx +106 -9
  8. package/src/components/Swap/SwapView/SwapButton/index.tsx +11 -11
  9. package/src/constants/index.ts +19 -2
  10. package/src/context/SwapProvider.tsx +7 -3
  11. package/src/services/api.ts +1 -0
  12. package/src/services/svm/README.md +483 -0
  13. package/src/services/svm/bindings/accounts/AllowedOfframp.ts +73 -0
  14. package/src/services/svm/bindings/accounts/Config.ts +153 -0
  15. package/src/services/svm/bindings/accounts/DestChain.ts +113 -0
  16. package/src/services/svm/bindings/accounts/Nonce.ts +97 -0
  17. package/src/services/svm/bindings/accounts/index.ts +15 -0
  18. package/src/services/svm/bindings/accounts/tokenAdminRegistry.ts +128 -0
  19. package/src/services/svm/bindings/errors/anchor.ts +773 -0
  20. package/src/services/svm/bindings/errors/custom.ts +375 -0
  21. package/src/services/svm/bindings/errors/index.ts +62 -0
  22. package/src/services/svm/bindings/instructions/ccipSend.ts +112 -0
  23. package/src/services/svm/bindings/instructions/getFee.ts +73 -0
  24. package/src/services/svm/bindings/instructions/index.ts +4 -0
  25. package/src/services/svm/bindings/programId.ts +6 -0
  26. package/src/services/svm/bindings/types/BaseChain.ts +92 -0
  27. package/src/services/svm/bindings/types/BaseConfig.ts +184 -0
  28. package/src/services/svm/bindings/types/CodeVersion.ts +88 -0
  29. package/src/services/svm/bindings/types/CrossChainAmount.ts +53 -0
  30. package/src/services/svm/bindings/types/DestChainConfig.ts +76 -0
  31. package/src/services/svm/bindings/types/DestChainState.ts +76 -0
  32. package/src/services/svm/bindings/types/GetFeeResult.ts +72 -0
  33. package/src/services/svm/bindings/types/LockOrBurnInV1.ts +102 -0
  34. package/src/services/svm/bindings/types/LockOrBurnOutV1.ts +79 -0
  35. package/src/services/svm/bindings/types/RampMessageHeader.ts +94 -0
  36. package/src/services/svm/bindings/types/RateLimitConfig.ts +72 -0
  37. package/src/services/svm/bindings/types/RateLimitTokenBucket.ts +76 -0
  38. package/src/services/svm/bindings/types/ReleaseOrMintInV1.ts +156 -0
  39. package/src/services/svm/bindings/types/ReleaseOrMintOutV1.ts +53 -0
  40. package/src/services/svm/bindings/types/RemoteAddress.ts +61 -0
  41. package/src/services/svm/bindings/types/RemoteConfig.ts +86 -0
  42. package/src/services/svm/bindings/types/RestoreOnAction.ts +120 -0
  43. package/src/services/svm/bindings/types/SVM2AnyMessage.ts +128 -0
  44. package/src/services/svm/bindings/types/SVM2AnyRampMessage.ts +166 -0
  45. package/src/services/svm/bindings/types/SVM2AnyTokenTransfer.ts +118 -0
  46. package/src/services/svm/bindings/types/SVMTokenAmount.ts +64 -0
  47. package/src/services/svm/bindings/types/index.ts +78 -0
  48. package/src/services/svm/core/client/accounts.ts +97 -0
  49. package/src/services/svm/core/client/events.ts +95 -0
  50. package/src/services/svm/core/client/fee.ts +279 -0
  51. package/src/services/svm/core/client/index.ts +150 -0
  52. package/src/services/svm/core/client/send.ts +607 -0
  53. package/src/services/svm/core/client/utils.ts +131 -0
  54. package/src/services/svm/core/models.ts +236 -0
  55. package/src/services/svm/index.ts +32 -0
  56. package/src/services/svm/utils/conversion.ts +62 -0
  57. package/src/services/svm/utils/errors.ts +51 -0
  58. package/src/services/svm/utils/keypair.ts +19 -0
  59. package/src/services/svm/utils/logger.ts +171 -0
  60. package/src/services/svm/utils/pdas/common.ts +15 -0
  61. package/src/services/svm/utils/pdas/feeQuoter.ts +68 -0
  62. package/src/services/svm/utils/pdas/index.ts +12 -0
  63. package/src/services/svm/utils/pdas/receiver.ts +58 -0
  64. package/src/services/svm/utils/pdas/rmnRemote.ts +23 -0
  65. package/src/services/svm/utils/pdas/router.ts +328 -0
  66. package/src/services/svm/utils/pdas/tokenpool.ts +161 -0
  67. package/src/services/svm/utils/transaction.ts +132 -0
  68. package/src/utils/validation.ts +7 -3
  69. package/tsconfig.json +2 -1
@@ -0,0 +1,102 @@
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 LockOrBurnInV1Fields {
7
+ receiver: Uint8Array
8
+ remoteChainSelector: BN
9
+ originalSender: PublicKey
10
+ amount: BN
11
+ localToken: PublicKey
12
+ }
13
+
14
+ export interface LockOrBurnInV1JSON {
15
+ receiver: Array<number>
16
+ remoteChainSelector: string
17
+ originalSender: string
18
+ amount: string
19
+ localToken: string
20
+ }
21
+
22
+ export class LockOrBurnInV1 {
23
+ readonly receiver: Uint8Array
24
+ readonly remoteChainSelector: BN
25
+ readonly originalSender: PublicKey
26
+ readonly amount: BN
27
+ readonly localToken: PublicKey
28
+
29
+ constructor(fields: LockOrBurnInV1Fields) {
30
+ this.receiver = fields.receiver
31
+ this.remoteChainSelector = fields.remoteChainSelector
32
+ this.originalSender = fields.originalSender
33
+ this.amount = fields.amount
34
+ this.localToken = fields.localToken
35
+ }
36
+
37
+ static layout(property?: string) {
38
+ return borsh.struct(
39
+ [
40
+ borsh.vecU8("receiver"),
41
+ borsh.u64("remoteChainSelector"),
42
+ borsh.publicKey("originalSender"),
43
+ borsh.u64("amount"),
44
+ borsh.publicKey("localToken"),
45
+ ],
46
+ property
47
+ )
48
+ }
49
+
50
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
+ static fromDecoded(obj: any) {
52
+ return new LockOrBurnInV1({
53
+ receiver: new Uint8Array(
54
+ obj.receiver.buffer,
55
+ obj.receiver.byteOffset,
56
+ obj.receiver.length
57
+ ),
58
+ remoteChainSelector: obj.remoteChainSelector,
59
+ originalSender: obj.originalSender,
60
+ amount: obj.amount,
61
+ localToken: obj.localToken,
62
+ })
63
+ }
64
+
65
+ static toEncodable(fields: LockOrBurnInV1Fields) {
66
+ return {
67
+ receiver: Buffer.from(
68
+ fields.receiver.buffer,
69
+ fields.receiver.byteOffset,
70
+ fields.receiver.length
71
+ ),
72
+ remoteChainSelector: fields.remoteChainSelector,
73
+ originalSender: fields.originalSender,
74
+ amount: fields.amount,
75
+ localToken: fields.localToken,
76
+ }
77
+ }
78
+
79
+ toJSON(): LockOrBurnInV1JSON {
80
+ return {
81
+ receiver: Array.from(this.receiver.values()),
82
+ remoteChainSelector: this.remoteChainSelector.toString(),
83
+ originalSender: this.originalSender.toString(),
84
+ amount: this.amount.toString(),
85
+ localToken: this.localToken.toString(),
86
+ }
87
+ }
88
+
89
+ static fromJSON(obj: LockOrBurnInV1JSON): LockOrBurnInV1 {
90
+ return new LockOrBurnInV1({
91
+ receiver: Uint8Array.from(obj.receiver),
92
+ remoteChainSelector: new BN(obj.remoteChainSelector),
93
+ originalSender: new PublicKey(obj.originalSender),
94
+ amount: new BN(obj.amount),
95
+ localToken: new PublicKey(obj.localToken),
96
+ })
97
+ }
98
+
99
+ toEncodable() {
100
+ return LockOrBurnInV1.toEncodable(this)
101
+ }
102
+ }
@@ -0,0 +1,79 @@
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 LockOrBurnOutV1Fields {
7
+ destTokenAddress: types.RemoteAddressFields
8
+ destPoolData: Uint8Array
9
+ }
10
+
11
+ export interface LockOrBurnOutV1JSON {
12
+ destTokenAddress: types.RemoteAddressJSON
13
+ destPoolData: Array<number>
14
+ }
15
+
16
+ export class LockOrBurnOutV1 {
17
+ readonly destTokenAddress: types.RemoteAddress
18
+ readonly destPoolData: Uint8Array
19
+
20
+ constructor(fields: LockOrBurnOutV1Fields) {
21
+ this.destTokenAddress = new types.RemoteAddress({
22
+ ...fields.destTokenAddress,
23
+ })
24
+ this.destPoolData = fields.destPoolData
25
+ }
26
+
27
+ static layout(property?: string) {
28
+ return borsh.struct(
29
+ [
30
+ types.RemoteAddress.layout("destTokenAddress"),
31
+ borsh.vecU8("destPoolData"),
32
+ ],
33
+ property
34
+ )
35
+ }
36
+
37
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
38
+ static fromDecoded(obj: any) {
39
+ return new LockOrBurnOutV1({
40
+ destTokenAddress: types.RemoteAddress.fromDecoded(obj.destTokenAddress),
41
+ destPoolData: new Uint8Array(
42
+ obj.destPoolData.buffer,
43
+ obj.destPoolData.byteOffset,
44
+ obj.destPoolData.length
45
+ ),
46
+ })
47
+ }
48
+
49
+ static toEncodable(fields: LockOrBurnOutV1Fields) {
50
+ return {
51
+ destTokenAddress: types.RemoteAddress.toEncodable(
52
+ fields.destTokenAddress
53
+ ),
54
+ destPoolData: Buffer.from(
55
+ fields.destPoolData.buffer,
56
+ fields.destPoolData.byteOffset,
57
+ fields.destPoolData.length
58
+ ),
59
+ }
60
+ }
61
+
62
+ toJSON(): LockOrBurnOutV1JSON {
63
+ return {
64
+ destTokenAddress: this.destTokenAddress.toJSON(),
65
+ destPoolData: Array.from(this.destPoolData.values()),
66
+ }
67
+ }
68
+
69
+ static fromJSON(obj: LockOrBurnOutV1JSON): LockOrBurnOutV1 {
70
+ return new LockOrBurnOutV1({
71
+ destTokenAddress: types.RemoteAddress.fromJSON(obj.destTokenAddress),
72
+ destPoolData: Uint8Array.from(obj.destPoolData),
73
+ })
74
+ }
75
+
76
+ toEncodable() {
77
+ return LockOrBurnOutV1.toEncodable(this)
78
+ }
79
+ }
@@ -0,0 +1,94 @@
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 RampMessageHeaderFields {
7
+ messageId: Array<number>
8
+ sourceChainSelector: BN
9
+ destChainSelector: BN
10
+ sequenceNumber: BN
11
+ nonce: BN
12
+ }
13
+
14
+ export interface RampMessageHeaderJSON {
15
+ messageId: Array<number>
16
+ sourceChainSelector: string
17
+ destChainSelector: string
18
+ sequenceNumber: string
19
+ nonce: string
20
+ }
21
+
22
+ export class RampMessageHeader {
23
+ readonly messageId: Array<number>
24
+ readonly sourceChainSelector: BN
25
+ readonly destChainSelector: BN
26
+ readonly sequenceNumber: BN
27
+ readonly nonce: BN
28
+
29
+ constructor(fields: RampMessageHeaderFields) {
30
+ this.messageId = fields.messageId
31
+ this.sourceChainSelector = fields.sourceChainSelector
32
+ this.destChainSelector = fields.destChainSelector
33
+ this.sequenceNumber = fields.sequenceNumber
34
+ this.nonce = fields.nonce
35
+ }
36
+
37
+ static layout(property?: string) {
38
+ return borsh.struct(
39
+ [
40
+ borsh.array(borsh.u8(), 32, "messageId"),
41
+ borsh.u64("sourceChainSelector"),
42
+ borsh.u64("destChainSelector"),
43
+ borsh.u64("sequenceNumber"),
44
+ borsh.u64("nonce"),
45
+ ],
46
+ property
47
+ )
48
+ }
49
+
50
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
51
+ static fromDecoded(obj: any) {
52
+ return new RampMessageHeader({
53
+ messageId: obj.messageId,
54
+ sourceChainSelector: obj.sourceChainSelector,
55
+ destChainSelector: obj.destChainSelector,
56
+ sequenceNumber: obj.sequenceNumber,
57
+ nonce: obj.nonce,
58
+ })
59
+ }
60
+
61
+ static toEncodable(fields: RampMessageHeaderFields) {
62
+ return {
63
+ messageId: fields.messageId,
64
+ sourceChainSelector: fields.sourceChainSelector,
65
+ destChainSelector: fields.destChainSelector,
66
+ sequenceNumber: fields.sequenceNumber,
67
+ nonce: fields.nonce,
68
+ }
69
+ }
70
+
71
+ toJSON(): RampMessageHeaderJSON {
72
+ return {
73
+ messageId: this.messageId,
74
+ sourceChainSelector: this.sourceChainSelector.toString(),
75
+ destChainSelector: this.destChainSelector.toString(),
76
+ sequenceNumber: this.sequenceNumber.toString(),
77
+ nonce: this.nonce.toString(),
78
+ }
79
+ }
80
+
81
+ static fromJSON(obj: RampMessageHeaderJSON): RampMessageHeader {
82
+ return new RampMessageHeader({
83
+ messageId: obj.messageId,
84
+ sourceChainSelector: new BN(obj.sourceChainSelector),
85
+ destChainSelector: new BN(obj.destChainSelector),
86
+ sequenceNumber: new BN(obj.sequenceNumber),
87
+ nonce: new BN(obj.nonce),
88
+ })
89
+ }
90
+
91
+ toEncodable() {
92
+ return RampMessageHeader.toEncodable(this)
93
+ }
94
+ }
@@ -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 RateLimitConfigFields {
7
+ enabled: boolean
8
+ capacity: BN
9
+ rate: BN
10
+ }
11
+
12
+ export interface RateLimitConfigJSON {
13
+ enabled: boolean
14
+ capacity: string
15
+ rate: string
16
+ }
17
+
18
+ export class RateLimitConfig {
19
+ readonly enabled: boolean
20
+ readonly capacity: BN
21
+ readonly rate: BN
22
+
23
+ constructor(fields: RateLimitConfigFields) {
24
+ this.enabled = fields.enabled
25
+ this.capacity = fields.capacity
26
+ this.rate = fields.rate
27
+ }
28
+
29
+ static layout(property?: string) {
30
+ return borsh.struct(
31
+ [borsh.bool("enabled"), borsh.u64("capacity"), borsh.u64("rate")],
32
+ property
33
+ )
34
+ }
35
+
36
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
37
+ static fromDecoded(obj: any) {
38
+ return new RateLimitConfig({
39
+ enabled: obj.enabled,
40
+ capacity: obj.capacity,
41
+ rate: obj.rate,
42
+ })
43
+ }
44
+
45
+ static toEncodable(fields: RateLimitConfigFields) {
46
+ return {
47
+ enabled: fields.enabled,
48
+ capacity: fields.capacity,
49
+ rate: fields.rate,
50
+ }
51
+ }
52
+
53
+ toJSON(): RateLimitConfigJSON {
54
+ return {
55
+ enabled: this.enabled,
56
+ capacity: this.capacity.toString(),
57
+ rate: this.rate.toString(),
58
+ }
59
+ }
60
+
61
+ static fromJSON(obj: RateLimitConfigJSON): RateLimitConfig {
62
+ return new RateLimitConfig({
63
+ enabled: obj.enabled,
64
+ capacity: new BN(obj.capacity),
65
+ rate: new BN(obj.rate),
66
+ })
67
+ }
68
+
69
+ toEncodable() {
70
+ return RateLimitConfig.toEncodable(this)
71
+ }
72
+ }
@@ -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 RateLimitTokenBucketFields {
7
+ tokens: BN
8
+ lastUpdated: BN
9
+ cfg: types.RateLimitConfigFields
10
+ }
11
+
12
+ export interface RateLimitTokenBucketJSON {
13
+ tokens: string
14
+ lastUpdated: string
15
+ cfg: types.RateLimitConfigJSON
16
+ }
17
+
18
+ export class RateLimitTokenBucket {
19
+ readonly tokens: BN
20
+ readonly lastUpdated: BN
21
+ readonly cfg: types.RateLimitConfig
22
+
23
+ constructor(fields: RateLimitTokenBucketFields) {
24
+ this.tokens = fields.tokens
25
+ this.lastUpdated = fields.lastUpdated
26
+ this.cfg = new types.RateLimitConfig({ ...fields.cfg })
27
+ }
28
+
29
+ static layout(property?: string) {
30
+ return borsh.struct(
31
+ [
32
+ borsh.u64("tokens"),
33
+ borsh.u64("lastUpdated"),
34
+ types.RateLimitConfig.layout("cfg"),
35
+ ],
36
+ property
37
+ )
38
+ }
39
+
40
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
41
+ static fromDecoded(obj: any) {
42
+ return new RateLimitTokenBucket({
43
+ tokens: obj.tokens,
44
+ lastUpdated: obj.lastUpdated,
45
+ cfg: types.RateLimitConfig.fromDecoded(obj.cfg),
46
+ })
47
+ }
48
+
49
+ static toEncodable(fields: RateLimitTokenBucketFields) {
50
+ return {
51
+ tokens: fields.tokens,
52
+ lastUpdated: fields.lastUpdated,
53
+ cfg: types.RateLimitConfig.toEncodable(fields.cfg),
54
+ }
55
+ }
56
+
57
+ toJSON(): RateLimitTokenBucketJSON {
58
+ return {
59
+ tokens: this.tokens.toString(),
60
+ lastUpdated: this.lastUpdated.toString(),
61
+ cfg: this.cfg.toJSON(),
62
+ }
63
+ }
64
+
65
+ static fromJSON(obj: RateLimitTokenBucketJSON): RateLimitTokenBucket {
66
+ return new RateLimitTokenBucket({
67
+ tokens: new BN(obj.tokens),
68
+ lastUpdated: new BN(obj.lastUpdated),
69
+ cfg: types.RateLimitConfig.fromJSON(obj.cfg),
70
+ })
71
+ }
72
+
73
+ toEncodable() {
74
+ return RateLimitTokenBucket.toEncodable(this)
75
+ }
76
+ }
@@ -0,0 +1,156 @@
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 ReleaseOrMintInV1Fields {
7
+ originalSender: types.RemoteAddressFields
8
+ remoteChainSelector: BN
9
+ receiver: PublicKey
10
+ amount: Array<number>
11
+ localToken: PublicKey
12
+ /**
13
+ * @dev WARNING: sourcePoolAddress should be checked prior to any processing of funds. Make sure it matches the
14
+ * expected pool address for the given remoteChainSelector.
15
+ */
16
+ sourcePoolAddress: types.RemoteAddressFields
17
+ sourcePoolData: Uint8Array
18
+ /** @dev WARNING: offchainTokenData is untrusted data. */
19
+ offchainTokenData: Uint8Array
20
+ }
21
+
22
+ export interface ReleaseOrMintInV1JSON {
23
+ originalSender: types.RemoteAddressJSON
24
+ remoteChainSelector: string
25
+ receiver: string
26
+ amount: Array<number>
27
+ localToken: string
28
+ /**
29
+ * @dev WARNING: sourcePoolAddress should be checked prior to any processing of funds. Make sure it matches the
30
+ * expected pool address for the given remoteChainSelector.
31
+ */
32
+ sourcePoolAddress: types.RemoteAddressJSON
33
+ sourcePoolData: Array<number>
34
+ /** @dev WARNING: offchainTokenData is untrusted data. */
35
+ offchainTokenData: Array<number>
36
+ }
37
+
38
+ export class ReleaseOrMintInV1 {
39
+ readonly originalSender: types.RemoteAddress
40
+ readonly remoteChainSelector: BN
41
+ readonly receiver: PublicKey
42
+ readonly amount: Array<number>
43
+ readonly localToken: PublicKey
44
+ /**
45
+ * @dev WARNING: sourcePoolAddress should be checked prior to any processing of funds. Make sure it matches the
46
+ * expected pool address for the given remoteChainSelector.
47
+ */
48
+ readonly sourcePoolAddress: types.RemoteAddress
49
+ readonly sourcePoolData: Uint8Array
50
+ /** @dev WARNING: offchainTokenData is untrusted data. */
51
+ readonly offchainTokenData: Uint8Array
52
+
53
+ constructor(fields: ReleaseOrMintInV1Fields) {
54
+ this.originalSender = new types.RemoteAddress({ ...fields.originalSender })
55
+ this.remoteChainSelector = fields.remoteChainSelector
56
+ this.receiver = fields.receiver
57
+ this.amount = fields.amount
58
+ this.localToken = fields.localToken
59
+ this.sourcePoolAddress = new types.RemoteAddress({
60
+ ...fields.sourcePoolAddress,
61
+ })
62
+ this.sourcePoolData = fields.sourcePoolData
63
+ this.offchainTokenData = fields.offchainTokenData
64
+ }
65
+
66
+ static layout(property?: string) {
67
+ return borsh.struct(
68
+ [
69
+ types.RemoteAddress.layout("originalSender"),
70
+ borsh.u64("remoteChainSelector"),
71
+ borsh.publicKey("receiver"),
72
+ borsh.array(borsh.u8(), 32, "amount"),
73
+ borsh.publicKey("localToken"),
74
+ types.RemoteAddress.layout("sourcePoolAddress"),
75
+ borsh.vecU8("sourcePoolData"),
76
+ borsh.vecU8("offchainTokenData"),
77
+ ],
78
+ property
79
+ )
80
+ }
81
+
82
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
83
+ static fromDecoded(obj: any) {
84
+ return new ReleaseOrMintInV1({
85
+ originalSender: types.RemoteAddress.fromDecoded(obj.originalSender),
86
+ remoteChainSelector: obj.remoteChainSelector,
87
+ receiver: obj.receiver,
88
+ amount: obj.amount,
89
+ localToken: obj.localToken,
90
+ sourcePoolAddress: types.RemoteAddress.fromDecoded(obj.sourcePoolAddress),
91
+ sourcePoolData: new Uint8Array(
92
+ obj.sourcePoolData.buffer,
93
+ obj.sourcePoolData.byteOffset,
94
+ obj.sourcePoolData.length
95
+ ),
96
+ offchainTokenData: new Uint8Array(
97
+ obj.offchainTokenData.buffer,
98
+ obj.offchainTokenData.byteOffset,
99
+ obj.offchainTokenData.length
100
+ ),
101
+ })
102
+ }
103
+
104
+ static toEncodable(fields: ReleaseOrMintInV1Fields) {
105
+ return {
106
+ originalSender: types.RemoteAddress.toEncodable(fields.originalSender),
107
+ remoteChainSelector: fields.remoteChainSelector,
108
+ receiver: fields.receiver,
109
+ amount: fields.amount,
110
+ localToken: fields.localToken,
111
+ sourcePoolAddress: types.RemoteAddress.toEncodable(
112
+ fields.sourcePoolAddress
113
+ ),
114
+ sourcePoolData: Buffer.from(
115
+ fields.sourcePoolData.buffer,
116
+ fields.sourcePoolData.byteOffset,
117
+ fields.sourcePoolData.length
118
+ ),
119
+ offchainTokenData: Buffer.from(
120
+ fields.offchainTokenData.buffer,
121
+ fields.offchainTokenData.byteOffset,
122
+ fields.offchainTokenData.length
123
+ ),
124
+ }
125
+ }
126
+
127
+ toJSON(): ReleaseOrMintInV1JSON {
128
+ return {
129
+ originalSender: this.originalSender.toJSON(),
130
+ remoteChainSelector: this.remoteChainSelector.toString(),
131
+ receiver: this.receiver.toString(),
132
+ amount: this.amount,
133
+ localToken: this.localToken.toString(),
134
+ sourcePoolAddress: this.sourcePoolAddress.toJSON(),
135
+ sourcePoolData: Array.from(this.sourcePoolData.values()),
136
+ offchainTokenData: Array.from(this.offchainTokenData.values()),
137
+ }
138
+ }
139
+
140
+ static fromJSON(obj: ReleaseOrMintInV1JSON): ReleaseOrMintInV1 {
141
+ return new ReleaseOrMintInV1({
142
+ originalSender: types.RemoteAddress.fromJSON(obj.originalSender),
143
+ remoteChainSelector: new BN(obj.remoteChainSelector),
144
+ receiver: new PublicKey(obj.receiver),
145
+ amount: obj.amount,
146
+ localToken: new PublicKey(obj.localToken),
147
+ sourcePoolAddress: types.RemoteAddress.fromJSON(obj.sourcePoolAddress),
148
+ sourcePoolData: Uint8Array.from(obj.sourcePoolData),
149
+ offchainTokenData: Uint8Array.from(obj.offchainTokenData),
150
+ })
151
+ }
152
+
153
+ toEncodable() {
154
+ return ReleaseOrMintInV1.toEncodable(this)
155
+ }
156
+ }
@@ -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 ReleaseOrMintOutV1Fields {
7
+ destinationAmount: BN
8
+ }
9
+
10
+ export interface ReleaseOrMintOutV1JSON {
11
+ destinationAmount: string
12
+ }
13
+
14
+ export class ReleaseOrMintOutV1 {
15
+ readonly destinationAmount: BN
16
+
17
+ constructor(fields: ReleaseOrMintOutV1Fields) {
18
+ this.destinationAmount = fields.destinationAmount
19
+ }
20
+
21
+ static layout(property?: string) {
22
+ return borsh.struct([borsh.u64("destinationAmount")], property)
23
+ }
24
+
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ static fromDecoded(obj: any) {
27
+ return new ReleaseOrMintOutV1({
28
+ destinationAmount: obj.destinationAmount,
29
+ })
30
+ }
31
+
32
+ static toEncodable(fields: ReleaseOrMintOutV1Fields) {
33
+ return {
34
+ destinationAmount: fields.destinationAmount,
35
+ }
36
+ }
37
+
38
+ toJSON(): ReleaseOrMintOutV1JSON {
39
+ return {
40
+ destinationAmount: this.destinationAmount.toString(),
41
+ }
42
+ }
43
+
44
+ static fromJSON(obj: ReleaseOrMintOutV1JSON): ReleaseOrMintOutV1 {
45
+ return new ReleaseOrMintOutV1({
46
+ destinationAmount: new BN(obj.destinationAmount),
47
+ })
48
+ }
49
+
50
+ toEncodable() {
51
+ return ReleaseOrMintOutV1.toEncodable(this)
52
+ }
53
+ }
@@ -0,0 +1,61 @@
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 RemoteAddressFields {
7
+ address: Uint8Array
8
+ }
9
+
10
+ export interface RemoteAddressJSON {
11
+ address: Array<number>
12
+ }
13
+
14
+ export class RemoteAddress {
15
+ readonly address: Uint8Array
16
+
17
+ constructor(fields: RemoteAddressFields) {
18
+ this.address = fields.address
19
+ }
20
+
21
+ static layout(property?: string) {
22
+ return borsh.struct([borsh.vecU8("address")], property)
23
+ }
24
+
25
+ // eslint-disable-next-line @typescript-eslint/no-explicit-any
26
+ static fromDecoded(obj: any) {
27
+ return new RemoteAddress({
28
+ address: new Uint8Array(
29
+ obj.address.buffer,
30
+ obj.address.byteOffset,
31
+ obj.address.length
32
+ ),
33
+ })
34
+ }
35
+
36
+ static toEncodable(fields: RemoteAddressFields) {
37
+ return {
38
+ address: Buffer.from(
39
+ fields.address.buffer,
40
+ fields.address.byteOffset,
41
+ fields.address.length
42
+ ),
43
+ }
44
+ }
45
+
46
+ toJSON(): RemoteAddressJSON {
47
+ return {
48
+ address: Array.from(this.address.values()),
49
+ }
50
+ }
51
+
52
+ static fromJSON(obj: RemoteAddressJSON): RemoteAddress {
53
+ return new RemoteAddress({
54
+ address: Uint8Array.from(obj.address),
55
+ })
56
+ }
57
+
58
+ toEncodable() {
59
+ return RemoteAddress.toEncodable(this)
60
+ }
61
+ }