@spacesops/pear-wrk-wdk 1.0.0-beta.14 → 1.0.0-beta.16

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spacesops/pear-wrk-wdk",
3
- "version": "1.0.0-beta.14",
3
+ "version": "1.0.0-beta.16",
4
4
  "main": "index.js",
5
5
  "scripts": {
6
6
  "build:types": "find . -name '*.d.ts' -not -path './node_modules/*' -not -path './types/*' -not -path './bundle/*' -delete && tsc",
@@ -15,7 +15,7 @@
15
15
  },
16
16
  "dependencies": {
17
17
  "@wdk/wallet": "https://github.com/tetherto/wdk-wallet#integration-rn-starter",
18
- "@wdk/wallet-btc": "npm:@spacesops/wdk-wallet-btc@^1.0.0-beta.8",
18
+ "@wdk/wallet-btc": "npm:@spacesops/wdk-wallet-btc@^1.0.0-beta.10",
19
19
  "@wdk/wallet-evm": "https://github.com/tetherto/wdk-wallet-evm#integration-rn-starter",
20
20
  "@wdk/wallet-evm-erc-4337": "https://github.com/tetherto/wdk-wallet-evm-erc-4337#integration-rn-starter",
21
21
  "@wdk/wallet-solana": "https://github.com/tetherto/wdk-wallet-solana#integration-rn-starter",
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 1,
2
+ "version": 3,
3
3
  "schema": [
4
4
  {
5
5
  "id": 0,
@@ -187,6 +187,32 @@
187
187
  "send": true
188
188
  },
189
189
  "version": 1
190
+ },
191
+ {
192
+ "id": 5,
193
+ "name": "@wdk-core/quoteSendTransactionWithMemo",
194
+ "request": {
195
+ "name": "@wdk-core/quoteSendTransactionWithMemo-request",
196
+ "stream": false
197
+ },
198
+ "response": {
199
+ "name": "@wdk-core/quoteSendTransactionWithMemo-response",
200
+ "stream": false
201
+ },
202
+ "version": 2
203
+ },
204
+ {
205
+ "id": 7,
206
+ "name": "@wdk-core/sendTransactionWithMemo",
207
+ "request": {
208
+ "name": "@wdk-core/sendTransactionWithMemo-request",
209
+ "stream": false
210
+ },
211
+ "response": {
212
+ "name": "@wdk-core/sendTransactionWithMemo-response",
213
+ "stream": false
214
+ },
215
+ "version": 3
190
216
  }
191
217
  ]
192
218
  }
@@ -34,7 +34,11 @@ const methods = new Map([
34
34
  ['@wdk-core/getTransactionReceipt', 13],
35
35
  [13, '@wdk-core/getTransactionReceipt'],
36
36
  ['@wdk-core/dispose', 14],
37
- [14, '@wdk-core/dispose']
37
+ [14, '@wdk-core/dispose'],
38
+ ['@wdk-core/quoteSendTransactionWithMemo', 15],
39
+ [15, '@wdk-core/quoteSendTransactionWithMemo'],
40
+ ['@wdk-core/sendTransactionWithMemo', 16],
41
+ [16, '@wdk-core/sendTransactionWithMemo']
38
42
  ])
39
43
 
40
44
  class HRPC {
@@ -56,7 +60,9 @@ class HRPC {
56
60
  ['@wdk-core/abstractedSendTransaction', getEncoding('@wdk-core/abstractedSendTransaction-request')],
57
61
  ['@wdk-core/abstractedAccountQuoteTransfer', getEncoding('@wdk-core/abstractedAccountQuoteTransfer-request')],
58
62
  ['@wdk-core/getTransactionReceipt', getEncoding('@wdk-core/getTransactionReceipt-request')],
59
- ['@wdk-core/dispose', getEncoding('@wdk-core/dispose-request')]
63
+ ['@wdk-core/dispose', getEncoding('@wdk-core/dispose-request')],
64
+ ['@wdk-core/quoteSendTransactionWithMemo', getEncoding('@wdk-core/quoteSendTransactionWithMemo-request')],
65
+ ['@wdk-core/sendTransactionWithMemo', getEncoding('@wdk-core/sendTransactionWithMemo-request')]
60
66
  ])
61
67
  this._responseEncodings = new Map([
62
68
  ['@wdk-core/workletStart', getEncoding('@wdk-core/workletStart-response')],
@@ -71,7 +77,9 @@ class HRPC {
71
77
  ['@wdk-core/getApproveTransaction', getEncoding('@wdk-core/getApproveTransaction-response')],
72
78
  ['@wdk-core/abstractedSendTransaction', getEncoding('@wdk-core/abstractedSendTransaction-response')],
73
79
  ['@wdk-core/abstractedAccountQuoteTransfer', getEncoding('@wdk-core/abstractedAccountQuoteTransfer-response')],
74
- ['@wdk-core/getTransactionReceipt', getEncoding('@wdk-core/getTransactionReceipt-response')]
80
+ ['@wdk-core/getTransactionReceipt', getEncoding('@wdk-core/getTransactionReceipt-response')],
81
+ ['@wdk-core/quoteSendTransactionWithMemo', getEncoding('@wdk-core/quoteSendTransactionWithMemo-response')],
82
+ ['@wdk-core/sendTransactionWithMemo', getEncoding('@wdk-core/sendTransactionWithMemo-response')]
75
83
  ])
76
84
  this._rpc = new RPC(stream, async (req) => {
77
85
  const command = methods.get(req.command)
@@ -195,6 +203,14 @@ class HRPC {
195
203
  return this._callSync('@wdk-core/dispose', args)
196
204
  }
197
205
 
206
+ async quoteSendTransactionWithMemo (args) {
207
+ return this._call('@wdk-core/quoteSendTransactionWithMemo', args)
208
+ }
209
+
210
+ async sendTransactionWithMemo (args) {
211
+ return this._call('@wdk-core/sendTransactionWithMemo', args)
212
+ }
213
+
198
214
  onLog (responseFn) {
199
215
  this._handlers['@wdk-core/log'] = responseFn
200
216
  }
@@ -255,6 +271,14 @@ class HRPC {
255
271
  this._handlers['@wdk-core/dispose'] = responseFn
256
272
  }
257
273
 
274
+ onQuoteSendTransactionWithMemo (responseFn) {
275
+ this._handlers['@wdk-core/quoteSendTransactionWithMemo'] = responseFn
276
+ }
277
+
278
+ onSendTransactionWithMemo (responseFn) {
279
+ this._handlers['@wdk-core/sendTransactionWithMemo'] = responseFn
280
+ }
281
+
258
282
  _requestIsStream (command) {
259
283
  return [
260
284
  ].includes(command)
@@ -1,11 +1,11 @@
1
1
  // This file is autogenerated by the hyperschema compiler
2
- // Schema Version: 1
2
+ // Schema Version: 3
3
3
  /* eslint-disable camelcase */
4
4
  /* eslint-disable quotes */
5
5
 
6
6
  const { c } = require('hyperschema/runtime')
7
7
 
8
- const VERSION = 1
8
+ const VERSION = 3
9
9
 
10
10
  // eslint-disable-next-line no-unused-vars
11
11
  let version = VERSION
@@ -728,6 +728,141 @@ const encoding38 = {
728
728
  }
729
729
  }
730
730
 
731
+ // @wdk-core/quoteSendTransactionWithMemo-request-options
732
+ const encoding39 = {
733
+ preencode (state, m) {
734
+ c.string.preencode(state, m.to)
735
+ c.string.preencode(state, m.value)
736
+ c.string.preencode(state, m.memo)
737
+ },
738
+ encode (state, m) {
739
+ c.string.encode(state, m.to)
740
+ c.string.encode(state, m.value)
741
+ c.string.encode(state, m.memo)
742
+ },
743
+ decode (state) {
744
+ const r0 = c.string.decode(state)
745
+ const r1 = c.string.decode(state)
746
+ const r2 = c.string.decode(state)
747
+
748
+ return {
749
+ to: r0,
750
+ value: r1,
751
+ memo: r2
752
+ }
753
+ }
754
+ }
755
+
756
+ // @wdk-core/quoteSendTransactionWithMemo-request.options
757
+ const encoding40_2 = c.frame(encoding39)
758
+
759
+ // @wdk-core/quoteSendTransactionWithMemo-request
760
+ const encoding40 = {
761
+ preencode (state, m) {
762
+ c.string.preencode(state, m.network)
763
+ c.uint.preencode(state, m.accountIndex)
764
+ encoding40_2.preencode(state, m.options)
765
+ },
766
+ encode (state, m) {
767
+ c.string.encode(state, m.network)
768
+ c.uint.encode(state, m.accountIndex)
769
+ encoding40_2.encode(state, m.options)
770
+ },
771
+ decode (state) {
772
+ const r0 = c.string.decode(state)
773
+ const r1 = c.uint.decode(state)
774
+ const r2 = encoding40_2.decode(state)
775
+
776
+ return {
777
+ network: r0,
778
+ accountIndex: r1,
779
+ options: r2
780
+ }
781
+ }
782
+ }
783
+
784
+ // @wdk-core/quoteSendTransactionWithMemo-response
785
+ const encoding41 = {
786
+ preencode (state, m) {
787
+ state.end++ // max flag is 1 so always one byte
788
+
789
+ if (version >= 2 && m.fee) c.string.preencode(state, m.fee)
790
+ },
791
+ encode (state, m) {
792
+ const flags = (version >= 2 && m.fee) ? 1 : 0
793
+
794
+ c.uint.encode(state, flags)
795
+
796
+ if (version >= 2 && m.fee) c.string.encode(state, m.fee)
797
+ },
798
+ decode (state) {
799
+ const flags = c.uint.decode(state)
800
+
801
+ return {
802
+ fee: (version >= 2 && (flags & 1) !== 0) ? c.string.decode(state) : null
803
+ }
804
+ }
805
+ }
806
+
807
+ // @wdk-core/sendTransactionWithMemo-request-options
808
+ const encoding42 = encoding39
809
+
810
+ // @wdk-core/sendTransactionWithMemo-request.options
811
+ const encoding43_2 = c.frame(encoding42)
812
+
813
+ // @wdk-core/sendTransactionWithMemo-request
814
+ const encoding43 = {
815
+ preencode (state, m) {
816
+ c.string.preencode(state, m.network)
817
+ c.uint.preencode(state, m.accountIndex)
818
+ encoding43_2.preencode(state, m.options)
819
+ },
820
+ encode (state, m) {
821
+ c.string.encode(state, m.network)
822
+ c.uint.encode(state, m.accountIndex)
823
+ encoding43_2.encode(state, m.options)
824
+ },
825
+ decode (state) {
826
+ const r0 = c.string.decode(state)
827
+ const r1 = c.uint.decode(state)
828
+ const r2 = encoding43_2.decode(state)
829
+
830
+ return {
831
+ network: r0,
832
+ accountIndex: r1,
833
+ options: r2
834
+ }
835
+ }
836
+ }
837
+
838
+ // @wdk-core/sendTransactionWithMemo-response
839
+ const encoding44 = {
840
+ preencode (state, m) {
841
+ state.end++ // max flag is 2 so always one byte
842
+
843
+ if (version >= 3 && m.fee) c.string.preencode(state, m.fee)
844
+ if (version >= 3 && m.hash) c.string.preencode(state, m.hash)
845
+ },
846
+ encode (state, m) {
847
+ const flags =
848
+ ((version >= 3 && m.fee) ? 1 : 0) |
849
+ ((version >= 3 && m.hash) ? 2 : 0)
850
+
851
+ c.uint.encode(state, flags)
852
+
853
+ if (version >= 3 && m.fee) c.string.encode(state, m.fee)
854
+ if (version >= 3 && m.hash) c.string.encode(state, m.hash)
855
+ },
856
+ decode (state) {
857
+ const flags = c.uint.decode(state)
858
+
859
+ return {
860
+ fee: (version >= 3 && (flags & 1) !== 0) ? c.string.decode(state) : null,
861
+ hash: (version >= 3 && (flags & 2) !== 0) ? c.string.decode(state) : null
862
+ }
863
+ }
864
+ }
865
+
731
866
  function setVersion (v) {
732
867
  version = v
733
868
  }
@@ -790,6 +925,12 @@ function getEncoding (name) {
790
925
  case '@wdk-core/getTransactionReceipt-request': return encoding36
791
926
  case '@wdk-core/getTransactionReceipt-response': return encoding37
792
927
  case '@wdk-core/dispose-request': return encoding38
928
+ case '@wdk-core/quoteSendTransactionWithMemo-request-options': return encoding39
929
+ case '@wdk-core/quoteSendTransactionWithMemo-request': return encoding40
930
+ case '@wdk-core/quoteSendTransactionWithMemo-response': return encoding41
931
+ case '@wdk-core/sendTransactionWithMemo-request-options': return encoding42
932
+ case '@wdk-core/sendTransactionWithMemo-request': return encoding43
933
+ case '@wdk-core/sendTransactionWithMemo-response': return encoding44
793
934
  default: throw new Error('Encoder not found ' + name)
794
935
  }
795
936
  }
@@ -1,11 +1,11 @@
1
1
  // This file is autogenerated by the hyperschema compiler
2
- // Schema Version: 1
2
+ // Schema Version: 3
3
3
  /* eslint-disable camelcase */
4
4
  /* eslint-disable quotes */
5
5
 
6
6
  const { c } = require('hyperschema/runtime')
7
7
 
8
- const VERSION = 1
8
+ const VERSION = 3
9
9
 
10
10
  // eslint-disable-next-line no-unused-vars
11
11
  let version = VERSION
@@ -728,6 +728,141 @@ const encoding38 = {
728
728
  }
729
729
  }
730
730
 
731
+ // @wdk-core/quoteSendTransactionWithMemo-request-options
732
+ const encoding39 = {
733
+ preencode (state, m) {
734
+ c.string.preencode(state, m.to)
735
+ c.string.preencode(state, m.value)
736
+ c.string.preencode(state, m.memo)
737
+ },
738
+ encode (state, m) {
739
+ c.string.encode(state, m.to)
740
+ c.string.encode(state, m.value)
741
+ c.string.encode(state, m.memo)
742
+ },
743
+ decode (state) {
744
+ const r0 = c.string.decode(state)
745
+ const r1 = c.string.decode(state)
746
+ const r2 = c.string.decode(state)
747
+
748
+ return {
749
+ to: r0,
750
+ value: r1,
751
+ memo: r2
752
+ }
753
+ }
754
+ }
755
+
756
+ // @wdk-core/quoteSendTransactionWithMemo-request.options
757
+ const encoding40_2 = c.frame(encoding39)
758
+
759
+ // @wdk-core/quoteSendTransactionWithMemo-request
760
+ const encoding40 = {
761
+ preencode (state, m) {
762
+ c.string.preencode(state, m.network)
763
+ c.uint.preencode(state, m.accountIndex)
764
+ encoding40_2.preencode(state, m.options)
765
+ },
766
+ encode (state, m) {
767
+ c.string.encode(state, m.network)
768
+ c.uint.encode(state, m.accountIndex)
769
+ encoding40_2.encode(state, m.options)
770
+ },
771
+ decode (state) {
772
+ const r0 = c.string.decode(state)
773
+ const r1 = c.uint.decode(state)
774
+ const r2 = encoding40_2.decode(state)
775
+
776
+ return {
777
+ network: r0,
778
+ accountIndex: r1,
779
+ options: r2
780
+ }
781
+ }
782
+ }
783
+
784
+ // @wdk-core/quoteSendTransactionWithMemo-response
785
+ const encoding41 = {
786
+ preencode (state, m) {
787
+ state.end++ // max flag is 1 so always one byte
788
+
789
+ if (version >= 2 && m.fee) c.string.preencode(state, m.fee)
790
+ },
791
+ encode (state, m) {
792
+ const flags = (version >= 2 && m.fee) ? 1 : 0
793
+
794
+ c.uint.encode(state, flags)
795
+
796
+ if (version >= 2 && m.fee) c.string.encode(state, m.fee)
797
+ },
798
+ decode (state) {
799
+ const flags = c.uint.decode(state)
800
+
801
+ return {
802
+ fee: (version >= 2 && (flags & 1) !== 0) ? c.string.decode(state) : null
803
+ }
804
+ }
805
+ }
806
+
807
+ // @wdk-core/sendTransactionWithMemo-request-options
808
+ const encoding42 = encoding39
809
+
810
+ // @wdk-core/sendTransactionWithMemo-request.options
811
+ const encoding43_2 = c.frame(encoding42)
812
+
813
+ // @wdk-core/sendTransactionWithMemo-request
814
+ const encoding43 = {
815
+ preencode (state, m) {
816
+ c.string.preencode(state, m.network)
817
+ c.uint.preencode(state, m.accountIndex)
818
+ encoding43_2.preencode(state, m.options)
819
+ },
820
+ encode (state, m) {
821
+ c.string.encode(state, m.network)
822
+ c.uint.encode(state, m.accountIndex)
823
+ encoding43_2.encode(state, m.options)
824
+ },
825
+ decode (state) {
826
+ const r0 = c.string.decode(state)
827
+ const r1 = c.uint.decode(state)
828
+ const r2 = encoding43_2.decode(state)
829
+
830
+ return {
831
+ network: r0,
832
+ accountIndex: r1,
833
+ options: r2
834
+ }
835
+ }
836
+ }
837
+
838
+ // @wdk-core/sendTransactionWithMemo-response
839
+ const encoding44 = {
840
+ preencode (state, m) {
841
+ state.end++ // max flag is 2 so always one byte
842
+
843
+ if (version >= 3 && m.fee) c.string.preencode(state, m.fee)
844
+ if (version >= 3 && m.hash) c.string.preencode(state, m.hash)
845
+ },
846
+ encode (state, m) {
847
+ const flags =
848
+ ((version >= 3 && m.fee) ? 1 : 0) |
849
+ ((version >= 3 && m.hash) ? 2 : 0)
850
+
851
+ c.uint.encode(state, flags)
852
+
853
+ if (version >= 3 && m.fee) c.string.encode(state, m.fee)
854
+ if (version >= 3 && m.hash) c.string.encode(state, m.hash)
855
+ },
856
+ decode (state) {
857
+ const flags = c.uint.decode(state)
858
+
859
+ return {
860
+ fee: (version >= 3 && (flags & 1) !== 0) ? c.string.decode(state) : null,
861
+ hash: (version >= 3 && (flags & 2) !== 0) ? c.string.decode(state) : null
862
+ }
863
+ }
864
+ }
865
+
731
866
  function setVersion (v) {
732
867
  version = v
733
868
  }
@@ -790,6 +925,12 @@ function getEncoding (name) {
790
925
  case '@wdk-core/getTransactionReceipt-request': return encoding36
791
926
  case '@wdk-core/getTransactionReceipt-response': return encoding37
792
927
  case '@wdk-core/dispose-request': return encoding38
928
+ case '@wdk-core/quoteSendTransactionWithMemo-request-options': return encoding39
929
+ case '@wdk-core/quoteSendTransactionWithMemo-request': return encoding40
930
+ case '@wdk-core/quoteSendTransactionWithMemo-response': return encoding41
931
+ case '@wdk-core/sendTransactionWithMemo-request-options': return encoding42
932
+ case '@wdk-core/sendTransactionWithMemo-request': return encoding43
933
+ case '@wdk-core/sendTransactionWithMemo-response': return encoding44
793
934
  default: throw new Error('Encoder not found ' + name)
794
935
  }
795
936
  }
@@ -1,5 +1,5 @@
1
1
  {
2
- "version": 1,
2
+ "version": 3,
3
3
  "schema": [
4
4
  {
5
5
  "name": "log-type-enum",
@@ -755,6 +755,141 @@
755
755
  "compact": false,
756
756
  "flagsPosition": -1,
757
757
  "fields": []
758
+ },
759
+ {
760
+ "name": "quoteSendTransactionWithMemo-request-options",
761
+ "namespace": "wdk-core",
762
+ "compact": false,
763
+ "flagsPosition": -1,
764
+ "fields": [
765
+ {
766
+ "name": "to",
767
+ "required": true,
768
+ "type": "string",
769
+ "version": 2
770
+ },
771
+ {
772
+ "name": "value",
773
+ "required": true,
774
+ "type": "string",
775
+ "version": 2
776
+ },
777
+ {
778
+ "name": "memo",
779
+ "required": true,
780
+ "type": "string",
781
+ "version": 2
782
+ }
783
+ ]
784
+ },
785
+ {
786
+ "name": "quoteSendTransactionWithMemo-request",
787
+ "namespace": "wdk-core",
788
+ "compact": false,
789
+ "flagsPosition": -1,
790
+ "fields": [
791
+ {
792
+ "name": "network",
793
+ "required": true,
794
+ "type": "string",
795
+ "version": 2
796
+ },
797
+ {
798
+ "name": "accountIndex",
799
+ "required": true,
800
+ "type": "uint",
801
+ "version": 2
802
+ },
803
+ {
804
+ "name": "options",
805
+ "required": true,
806
+ "type": "@wdk-core/quoteSendTransactionWithMemo-request-options",
807
+ "version": 2
808
+ }
809
+ ]
810
+ },
811
+ {
812
+ "name": "quoteSendTransactionWithMemo-response",
813
+ "namespace": "wdk-core",
814
+ "compact": false,
815
+ "flagsPosition": 0,
816
+ "fields": [
817
+ {
818
+ "name": "fee",
819
+ "type": "string",
820
+ "version": 2
821
+ }
822
+ ]
823
+ },
824
+ {
825
+ "name": "sendTransactionWithMemo-request-options",
826
+ "namespace": "wdk-core",
827
+ "compact": false,
828
+ "flagsPosition": -1,
829
+ "fields": [
830
+ {
831
+ "name": "to",
832
+ "required": true,
833
+ "type": "string",
834
+ "version": 3
835
+ },
836
+ {
837
+ "name": "value",
838
+ "required": true,
839
+ "type": "string",
840
+ "version": 3
841
+ },
842
+ {
843
+ "name": "memo",
844
+ "required": true,
845
+ "type": "string",
846
+ "version": 3
847
+ }
848
+ ]
849
+ },
850
+ {
851
+ "name": "sendTransactionWithMemo-request",
852
+ "namespace": "wdk-core",
853
+ "compact": false,
854
+ "flagsPosition": -1,
855
+ "fields": [
856
+ {
857
+ "name": "network",
858
+ "required": true,
859
+ "type": "string",
860
+ "version": 3
861
+ },
862
+ {
863
+ "name": "accountIndex",
864
+ "required": true,
865
+ "type": "uint",
866
+ "version": 3
867
+ },
868
+ {
869
+ "name": "options",
870
+ "required": true,
871
+ "type": "@wdk-core/sendTransactionWithMemo-request-options",
872
+ "version": 3
873
+ }
874
+ ]
875
+ },
876
+ {
877
+ "name": "sendTransactionWithMemo-response",
878
+ "namespace": "wdk-core",
879
+ "compact": false,
880
+ "flagsPosition": 0,
881
+ "fields": [
882
+ {
883
+ "name": "fee",
884
+ "type": "string",
885
+ "version": 3
886
+ },
887
+ {
888
+ "name": "hash",
889
+ "type": "string",
890
+ "version": 3
891
+ }
892
+ ]
758
893
  }
759
894
  ]
760
895
  }
@@ -103,6 +103,33 @@ schemaNs.register({
103
103
  ]
104
104
  })
105
105
 
106
+ /**
107
+ * quoteSendTransactionWithMemo
108
+ */
109
+ schemaNs.register({
110
+ name: 'quoteSendTransactionWithMemo-request-options',
111
+ fields: [
112
+ { name: 'to', type: 'string', required: true },
113
+ { name: 'value', type: 'string', required: true },
114
+ { name: 'memo', type: 'string', required: true }
115
+ ]
116
+ })
117
+ schemaNs.register({
118
+ name: 'quoteSendTransactionWithMemo-request',
119
+ fields: [
120
+ { name: 'network', type: 'string', required: true },
121
+ { name: 'accountIndex', type: 'uint', required: true },
122
+ { name: 'options', type: '@wdk-core/quoteSendTransactionWithMemo-request-options', required: true }
123
+ ]
124
+ })
125
+
126
+ schemaNs.register({
127
+ name: 'quoteSendTransactionWithMemo-response',
128
+ fields: [
129
+ { name: 'fee', type: 'string' }
130
+ ]
131
+ })
132
+
106
133
  /**
107
134
  * sendTransaction
108
135
  */
@@ -130,6 +157,34 @@ schemaNs.register({
130
157
  ]
131
158
  })
132
159
 
160
+ /**
161
+ * sendTransactionWithMemo
162
+ */
163
+ schemaNs.register({
164
+ name: 'sendTransactionWithMemo-request-options',
165
+ fields: [
166
+ { name: 'to', type: 'string', required: true },
167
+ { name: 'value', type: 'string', required: true },
168
+ { name: 'memo', type: 'string', required: true }
169
+ ]
170
+ })
171
+ schemaNs.register({
172
+ name: 'sendTransactionWithMemo-request',
173
+ fields: [
174
+ { name: 'network', type: 'string', required: true },
175
+ { name: 'accountIndex', type: 'uint', required: true },
176
+ { name: 'options', type: '@wdk-core/sendTransactionWithMemo-request-options', required: true }
177
+ ]
178
+ })
179
+
180
+ schemaNs.register({
181
+ name: 'sendTransactionWithMemo-response',
182
+ fields: [
183
+ { name: 'fee', type: 'string' },
184
+ { name: 'hash', type: 'string' }
185
+ ]
186
+ })
187
+
133
188
  /********************
134
189
  *
135
190
  * ABSTRACTION
@@ -382,12 +437,24 @@ ns.register({
382
437
  response: { name: '@wdk-core/quoteSendTransaction-response', stream: false }
383
438
  })
384
439
 
440
+ ns.register({
441
+ name: 'quoteSendTransactionWithMemo',
442
+ request: { name: '@wdk-core/quoteSendTransactionWithMemo-request', stream: false },
443
+ response: { name: '@wdk-core/quoteSendTransactionWithMemo-response', stream: false }
444
+ })
445
+
385
446
  ns.register({
386
447
  name: 'sendTransaction',
387
448
  request: { name: '@wdk-core/sendTransaction-request', stream: false },
388
449
  response: { name: '@wdk-core/sendTransaction-response', stream: false }
389
450
  })
390
451
 
452
+ ns.register({
453
+ name: 'sendTransactionWithMemo',
454
+ request: { name: '@wdk-core/sendTransactionWithMemo-request', stream: false },
455
+ response: { name: '@wdk-core/sendTransactionWithMemo-response', stream: false }
456
+ })
457
+
391
458
  ns.register({
392
459
  name: 'getAbstractedAddress',
393
460
  request: { name: '@wdk-core/getAbstractedAddress-request', stream: false },
@@ -259,6 +259,29 @@ class WdkManager {
259
259
  return await account.quoteSendTransaction(options)
260
260
  }
261
261
 
262
+ /**
263
+ * Quotes a transaction with memo for Bitcoin blockchain.
264
+ *
265
+ * @param {Blockchain} blockchain - A blockchain identifier (must be "bitcoin").
266
+ * @param {number} accountIndex - The index of the account to use (see [BIP-44](https://en.bitcoin.it/wiki/BIP_0044)).
267
+ * @param {Transaction} options - The transaction options including memo.
268
+ * @returns {Promise<Omit<TransactionResult, "hash">>} The transaction quote result.
269
+ * @throws {Error} If blockchain is not Bitcoin.
270
+ */
271
+ async quoteSendTransactionWithMemo (blockchain, accountIndex, options) {
272
+ if (blockchain !== Blockchain.Bitcoin) {
273
+ throw new Error(`quoteSendTransactionWithMemo is only supported for Bitcoin blockchain. Received: ${blockchain}`)
274
+ }
275
+
276
+ const account = await this.getAccount(blockchain, accountIndex)
277
+
278
+ if (typeof account.quoteSendTransactionWithMemo !== 'function') {
279
+ throw new Error('quoteSendTransactionWithMemo is not supported by this account')
280
+ }
281
+
282
+ return await account.quoteSendTransactionWithMemo(options)
283
+ }
284
+
262
285
  /**
263
286
  * Transfers a token to another address.
264
287
  *
@@ -282,6 +305,29 @@ class WdkManager {
282
305
  return await account.sendTransaction(options)
283
306
  }
284
307
 
308
+ /**
309
+ * Sends a transaction with memo for Bitcoin blockchain.
310
+ *
311
+ * @param {Blockchain} blockchain - A blockchain identifier (must be "bitcoin").
312
+ * @param {number} accountIndex - The index of the account to use (see [BIP-44](https://en.bitcoin.it/wiki/BIP_0044)).
313
+ * @param {Transaction} options - The transaction options including memo.
314
+ * @returns {Promise<TransactionResult>} The transaction result.
315
+ * @throws {Error} If blockchain is not Bitcoin.
316
+ */
317
+ async sendTransactionWithMemo (blockchain, accountIndex, options) {
318
+ if (blockchain !== Blockchain.Bitcoin) {
319
+ throw new Error(`sendTransactionWithMemo is only supported for Bitcoin blockchain. Received: ${blockchain}`)
320
+ }
321
+
322
+ const account = await this.getAccount(blockchain, accountIndex)
323
+
324
+ if (typeof account.sendTransactionWithMemo !== 'function') {
325
+ throw new Error('sendTransactionWithMemo is not supported by this account')
326
+ }
327
+
328
+ return await account.sendTransactionWithMemo(options)
329
+ }
330
+
285
331
  /**
286
332
  * Returns the abstracted address of an account.
287
333
  *
@@ -50,6 +50,17 @@ rpc.onQuoteSendTransaction(async payload => {
50
50
  }
51
51
  })
52
52
 
53
+ rpc.onQuoteSendTransactionWithMemo(async payload => {
54
+ try {
55
+ // Convert amount value to number
56
+ payload.options.value = Number(payload.options.value)
57
+ const transaction = await wdk.quoteSendTransactionWithMemo(payload.network, payload.accountIndex, payload.options)
58
+ return { fee: transaction.fee.toString() }
59
+ } catch (error) {
60
+ throw new Error(rpcException.stringifyError(error))
61
+ }
62
+ })
63
+
53
64
  rpc.onSendTransaction(async payload => {
54
65
  try {
55
66
  payload.options.value = Number(payload.options.value)
@@ -60,6 +71,16 @@ rpc.onSendTransaction(async payload => {
60
71
  }
61
72
  })
62
73
 
74
+ rpc.onSendTransactionWithMemo(async payload => {
75
+ try {
76
+ payload.options.value = Number(payload.options.value)
77
+ const transaction = await wdk.sendTransactionWithMemo(payload.network, payload.accountIndex, payload.options)
78
+ return { fee: transaction.fee.toString(), hash: transaction.hash }
79
+ } catch (error) {
80
+ throw new Error(rpcException.stringifyError(error))
81
+ }
82
+ })
83
+
63
84
  /*****************
64
85
  *
65
86
  * ABSTRACTION
package/src/worklet.mjs CHANGED
@@ -50,6 +50,17 @@ rpc.onQuoteSendTransaction(async payload => {
50
50
  }
51
51
  })
52
52
 
53
+ rpc.onQuoteSendTransactionWithMemo(async payload => {
54
+ try {
55
+ // Convert amount value to number
56
+ payload.options.value = Number(payload.options.value)
57
+ const transaction = await wdk.quoteSendTransactionWithMemo(payload.network, payload.accountIndex, payload.options)
58
+ return { fee: transaction.fee.toString() }
59
+ } catch (error) {
60
+ throw new Error(stringifyError(error))
61
+ }
62
+ })
63
+
53
64
  rpc.onSendTransaction(async payload => {
54
65
  try {
55
66
  payload.options.value = Number(payload.options.value)
@@ -60,6 +71,16 @@ rpc.onSendTransaction(async payload => {
60
71
  }
61
72
  })
62
73
 
74
+ rpc.onSendTransactionWithMemo(async payload => {
75
+ try {
76
+ payload.options.value = Number(payload.options.value)
77
+ const transaction = await wdk.sendTransactionWithMemo(payload.network, payload.accountIndex, payload.options)
78
+ return { fee: transaction.fee.toString(), hash: transaction.hash }
79
+ } catch (error) {
80
+ throw new Error(stringifyError(error))
81
+ }
82
+ })
83
+
63
84
  /*****************
64
85
  *
65
86
  * ABSTRACTION