@directcryptopay/sdk 0.2.4 → 0.3.0

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 (127) hide show
  1. package/README.md +51 -87
  2. package/dist/core/config.d.ts +9 -46
  3. package/dist/core/iframe.d.ts +16 -0
  4. package/dist/dcp-sdk.umd.js +1 -12811
  5. package/dist/dcp.d.ts +12 -5
  6. package/dist/index.d.ts +1 -1
  7. package/dist/index.js +219 -2
  8. package/dist/types.d.ts +26 -164
  9. package/package.json +3 -13
  10. package/dist/ExchangeController-CbO41bcH.js +0 -217
  11. package/dist/HelpersUtil-DHm6EVSE.js +0 -120
  12. package/dist/NavigationUtil-kj9LEOOd.js +0 -8
  13. package/dist/PhArrowCircleDown-lsK25DCk.js +0 -73
  14. package/dist/PhArrowClockwise-NeKHZ1co.js +0 -73
  15. package/dist/PhArrowDown-C9AkNvLs.js +0 -73
  16. package/dist/PhArrowLeft-RNfIQP1X.js +0 -73
  17. package/dist/PhArrowRight-DM1tna0G.js +0 -73
  18. package/dist/PhArrowSquareOut-S5XYbAZj.js +0 -73
  19. package/dist/PhArrowUp-DmktzOWy.js +0 -73
  20. package/dist/PhArrowUpRight-BkNeW_5i.js +0 -73
  21. package/dist/PhArrowsClockwise-CQ4pG76b.js +0 -73
  22. package/dist/PhArrowsDownUp-H6gxaNM6.js +0 -73
  23. package/dist/PhArrowsLeftRight-DZSsfMR6.js +0 -73
  24. package/dist/PhBank-4_9QzqIB.js +0 -73
  25. package/dist/PhBrowser-B-JSznId.js +0 -73
  26. package/dist/PhCaretDown-vV5oHMNi.js +0 -73
  27. package/dist/PhCaretLeft-BLo6Y_f4.js +0 -73
  28. package/dist/PhCaretRight-CqQN4TT3.js +0 -73
  29. package/dist/PhCaretUp-Df7UCAHy.js +0 -73
  30. package/dist/PhCheck-gtpfK4ed.js +0 -73
  31. package/dist/PhCircleHalf-Uq7dwDYw.js +0 -73
  32. package/dist/PhClock-SDCW-NmF.js +0 -73
  33. package/dist/PhCompass-B7hgtdx-.js +0 -73
  34. package/dist/PhCopy-BcnhyXCy.js +0 -73
  35. package/dist/PhCreditCard-BJjByVgu.js +0 -73
  36. package/dist/PhCurrencyDollar-B7ZXqXBy.js +0 -73
  37. package/dist/PhDesktop-B3VKPuJx.js +0 -73
  38. package/dist/PhDeviceMobile-Bnd0TYEH.js +0 -73
  39. package/dist/PhDotsThree-yyMWyZ-R.js +0 -73
  40. package/dist/PhEnvelope-67uzHbI9.js +0 -73
  41. package/dist/PhFunnelSimple-B-DCsloI.js +0 -73
  42. package/dist/PhGlobe-TMm_6qGk.js +0 -73
  43. package/dist/PhIdentificationCard-CePPD2xc.js +0 -73
  44. package/dist/PhImage-gY96WtHR.js +0 -73
  45. package/dist/PhInfo-DRQM_ZDP.js +0 -73
  46. package/dist/PhLightbulb-B0TxPfZ1.js +0 -73
  47. package/dist/PhMagnifyingGlass-B8si5_6W.js +0 -73
  48. package/dist/PhPaperPlaneRight-DVu5PLYd.js +0 -73
  49. package/dist/PhPlus-BfTsQnUz.js +0 -73
  50. package/dist/PhPower-CxYUGOWn.js +0 -73
  51. package/dist/PhPuzzlePiece-CQ4wh0gV.js +0 -73
  52. package/dist/PhQrCode-BuJ97NYJ.js +0 -73
  53. package/dist/PhQuestion-kJoP8Mja.js +0 -73
  54. package/dist/PhQuestionMark-C46ZkFpu.js +0 -73
  55. package/dist/PhSealCheck-Eh8jVqSN.js +0 -73
  56. package/dist/PhSignOut-jk97OSVt.js +0 -73
  57. package/dist/PhSpinner-CiYOhwMg.js +0 -73
  58. package/dist/PhTrash-pxerMqzd.js +0 -73
  59. package/dist/PhUser-BMg0VV4A.js +0 -73
  60. package/dist/PhVault-DYQvx5A-.js +0 -73
  61. package/dist/PhWarning-NLC5Mj87.js +0 -73
  62. package/dist/PhWarningCircle-Ch2jU9fA.js +0 -73
  63. package/dist/PhX-Bx4wpwm3.js +0 -73
  64. package/dist/SwapController-Ch0FFTEt.js +0 -457
  65. package/dist/ccip-BrGhNXIM.js +0 -150
  66. package/dist/core/api.d.ts +0 -39
  67. package/dist/core/logic.d.ts +0 -2
  68. package/dist/core/wallet.d.ts +0 -55
  69. package/dist/data-capture-CpafmuCb.js +0 -490
  70. package/dist/email-Dcg4jlai.js +0 -344
  71. package/dist/embedded-wallet-DeoRdAPw.js +0 -820
  72. package/dist/features-B9Nde43h.js +0 -274
  73. package/dist/hashTypedData-a7b8tdkO.js +0 -197
  74. package/dist/if-defined-k21LutCn.js +0 -10
  75. package/dist/index-9vLw53Xl.js +0 -228
  76. package/dist/index-B5wUyynz.js +0 -107
  77. package/dist/index-B8LkUrww.js +0 -86
  78. package/dist/index-BA0VwKg0.js +0 -8189
  79. package/dist/index-BB9JJ24N.js +0 -125
  80. package/dist/index-BCkEvPQ6.js +0 -172
  81. package/dist/index-BDeO_csr.js +0 -171
  82. package/dist/index-Bb7babLF.js +0 -1281
  83. package/dist/index-BjOhprVS.js +0 -199
  84. package/dist/index-BjyMgZsf.js +0 -218
  85. package/dist/index-BkThIDLX.js +0 -159
  86. package/dist/index-BmFs6nb7.js +0 -209
  87. package/dist/index-C1QEJL-2.js +0 -572
  88. package/dist/index-C4qc4PdD.js +0 -387
  89. package/dist/index-CAPvUh14.js +0 -1750
  90. package/dist/index-CBMU3PTE.js +0 -65
  91. package/dist/index-CGwPkJLF.js +0 -355
  92. package/dist/index-CNGEqX3D.js +0 -153
  93. package/dist/index-CRlCq6IB.js +0 -7981
  94. package/dist/index-Cg_o-i9X.js +0 -118
  95. package/dist/index-D1BvhCbI.js +0 -62
  96. package/dist/index-DFi8TiHc.js +0 -128
  97. package/dist/index-DLwuveL9.js +0 -555
  98. package/dist/index-DMn7ktUQ.js +0 -56
  99. package/dist/index-DOXwtuwa.js +0 -117
  100. package/dist/index-DPPOW_Tp.js +0 -118
  101. package/dist/index-DQpzHpW-.js +0 -517
  102. package/dist/index-DXHg5C-W.js +0 -276
  103. package/dist/index-DcYjZV4H.js +0 -110
  104. package/dist/index-DeL88Lwc.js +0 -41655
  105. package/dist/index-DrWVlf8b.js +0 -46
  106. package/dist/index-Dsfuc4rB.js +0 -123
  107. package/dist/index-DuTny38n.js +0 -1175
  108. package/dist/index-Nfjb6bV0.js +0 -21991
  109. package/dist/index-WwwdQSN2.js +0 -85
  110. package/dist/index-Yha9Afch.js +0 -174
  111. package/dist/index-cbQHN7GC.js +0 -100
  112. package/dist/index-hyG3cYsv.js +0 -1083
  113. package/dist/index-qLxmmPaL.js +0 -257
  114. package/dist/localBatchGatewayRequest-vfcvRH0G.js +0 -91
  115. package/dist/onramp-BSiyOX4L.js +0 -855
  116. package/dist/parseSignature-CdCMAPZN.js +0 -3304
  117. package/dist/pay-with-exchange-CduNoMEz.js +0 -525
  118. package/dist/property-Bd8U3_QP.js +0 -618
  119. package/dist/receive-CrmptJlq.js +0 -232
  120. package/dist/ref-SOwYtCZb.js +0 -107
  121. package/dist/send-oMcHMEr6.js +0 -1166
  122. package/dist/socials-C0A4-FbY.js +0 -620
  123. package/dist/swaps-CbJJ9Ciu.js +0 -1760
  124. package/dist/transactions-BDfCoBS5.js +0 -37
  125. package/dist/ui/Modal.d.ts +0 -9
  126. package/dist/ui/index.d.ts +0 -6
  127. package/dist/w3m-modal-BjsTkny7.js +0 -1706
@@ -1,387 +0,0 @@
1
- import { r as T } from "./index-C1QEJL-2.js";
2
- import { bk as y } from "./index-DeL88Lwc.js";
3
- import { h as k, e as I } from "./hashTypedData-a7b8tdkO.js";
4
- const q = () => "9.1.0", v = (t) => t.toString(16).padStart(2, "0"), C = (t) => {
5
- const e = new Uint8Array(t / 2);
6
- return window.crypto.getRandomValues(e), Array.from(e, v).join("");
7
- }, R = () => typeof window < "u" ? C(10) : (/* @__PURE__ */ new Date()).getTime().toString(36);
8
- class g {
9
- }
10
- g.makeRequest = (t, e) => ({
11
- id: R(),
12
- method: t,
13
- params: e,
14
- env: {
15
- sdkVersion: q()
16
- }
17
- });
18
- g.makeResponse = (t, e, s) => ({
19
- id: t,
20
- success: !0,
21
- version: s,
22
- data: e
23
- });
24
- g.makeErrorResponse = (t, e, s) => ({
25
- id: t,
26
- success: !1,
27
- error: e,
28
- version: s
29
- });
30
- var r;
31
- (function(t) {
32
- t.sendTransactions = "sendTransactions", t.rpcCall = "rpcCall", t.getChainInfo = "getChainInfo", t.getSafeInfo = "getSafeInfo", t.getTxBySafeTxHash = "getTxBySafeTxHash", t.getSafeBalances = "getSafeBalances", t.signMessage = "signMessage", t.signTypedMessage = "signTypedMessage", t.getEnvironmentInfo = "getEnvironmentInfo", t.getOffChainSignature = "getOffChainSignature", t.requestAddressBook = "requestAddressBook", t.wallet_getPermissions = "wallet_getPermissions", t.wallet_requestPermissions = "wallet_requestPermissions";
33
- })(r || (r = {}));
34
- var m;
35
- (function(t) {
36
- t.requestAddressBook = "requestAddressBook";
37
- })(m || (m = {}));
38
- class H {
39
- constructor(e = null, s = !1) {
40
- this.allowedOrigins = null, this.callbacks = /* @__PURE__ */ new Map(), this.debugMode = !1, this.isServer = typeof window > "u", this.isValidMessage = ({ origin: a, data: n, source: i }) => {
41
- const o = !n, l = !this.isServer && i === window.parent, u = typeof n.version < "u" && parseInt(n.version.split(".")[0]), B = typeof u == "number" && u >= 1;
42
- let p = !0;
43
- return Array.isArray(this.allowedOrigins) && (p = this.allowedOrigins.find((P) => P.test(a)) !== void 0), !o && l && B && p;
44
- }, this.logIncomingMessage = (a) => {
45
- console.info(`Safe Apps SDK v1: A message was received from origin ${a.origin}. `, a.data);
46
- }, this.onParentMessage = (a) => {
47
- this.isValidMessage(a) && (this.debugMode && this.logIncomingMessage(a), this.handleIncomingMessage(a.data));
48
- }, this.handleIncomingMessage = (a) => {
49
- const { id: n } = a, i = this.callbacks.get(n);
50
- i && (i(a), this.callbacks.delete(n));
51
- }, this.send = (a, n) => {
52
- const i = g.makeRequest(a, n);
53
- if (this.isServer)
54
- throw new Error("Window doesn't exist");
55
- return window.parent.postMessage(i, "*"), new Promise((o, l) => {
56
- this.callbacks.set(i.id, (u) => {
57
- if (!u.success) {
58
- l(new Error(u.error));
59
- return;
60
- }
61
- o(u);
62
- });
63
- });
64
- }, this.allowedOrigins = e, this.debugMode = s, this.isServer || window.addEventListener("message", this.onParentMessage);
65
- }
66
- }
67
- const b = (t) => typeof t == "object" && t != null && "domain" in t && "types" in t && "message" in t;
68
- T();
69
- class E {
70
- constructor(e) {
71
- this.communicator = e;
72
- }
73
- async getBySafeTxHash(e) {
74
- if (!e)
75
- throw new Error("Invalid safeTxHash");
76
- return (await this.communicator.send(r.getTxBySafeTxHash, { safeTxHash: e })).data;
77
- }
78
- async signMessage(e) {
79
- const s = {
80
- message: e
81
- };
82
- return (await this.communicator.send(r.signMessage, s)).data;
83
- }
84
- async signTypedMessage(e) {
85
- if (!b(e))
86
- throw new Error("Invalid typed data");
87
- return (await this.communicator.send(r.signTypedMessage, { typedData: e })).data;
88
- }
89
- async send({ txs: e, params: s }) {
90
- if (!e || !e.length)
91
- throw new Error("No transactions were passed");
92
- const a = {
93
- txs: e,
94
- params: s
95
- };
96
- return (await this.communicator.send(r.sendTransactions, a)).data;
97
- }
98
- }
99
- const c = {
100
- eth_call: "eth_call",
101
- eth_gasPrice: "eth_gasPrice",
102
- eth_getLogs: "eth_getLogs",
103
- eth_getBalance: "eth_getBalance",
104
- eth_getCode: "eth_getCode",
105
- eth_getBlockByHash: "eth_getBlockByHash",
106
- eth_getBlockByNumber: "eth_getBlockByNumber",
107
- eth_getStorageAt: "eth_getStorageAt",
108
- eth_getTransactionByHash: "eth_getTransactionByHash",
109
- eth_getTransactionReceipt: "eth_getTransactionReceipt",
110
- eth_getTransactionCount: "eth_getTransactionCount",
111
- eth_estimateGas: "eth_estimateGas",
112
- safe_setSettings: "safe_setSettings"
113
- }, h = {
114
- defaultBlockParam: (t = "latest") => t,
115
- returnFullTxObjectParam: (t = !1) => t,
116
- blockNumberToHex: (t) => Number.isInteger(t) ? `0x${t.toString(16)}` : t
117
- };
118
- class A {
119
- constructor(e) {
120
- this.communicator = e, this.call = this.buildRequest({
121
- call: c.eth_call,
122
- formatters: [null, h.defaultBlockParam]
123
- }), this.getBalance = this.buildRequest({
124
- call: c.eth_getBalance,
125
- formatters: [null, h.defaultBlockParam]
126
- }), this.getCode = this.buildRequest({
127
- call: c.eth_getCode,
128
- formatters: [null, h.defaultBlockParam]
129
- }), this.getStorageAt = this.buildRequest({
130
- call: c.eth_getStorageAt,
131
- formatters: [null, h.blockNumberToHex, h.defaultBlockParam]
132
- }), this.getPastLogs = this.buildRequest({
133
- call: c.eth_getLogs
134
- }), this.getBlockByHash = this.buildRequest({
135
- call: c.eth_getBlockByHash,
136
- formatters: [null, h.returnFullTxObjectParam]
137
- }), this.getBlockByNumber = this.buildRequest({
138
- call: c.eth_getBlockByNumber,
139
- formatters: [h.blockNumberToHex, h.returnFullTxObjectParam]
140
- }), this.getTransactionByHash = this.buildRequest({
141
- call: c.eth_getTransactionByHash
142
- }), this.getTransactionReceipt = this.buildRequest({
143
- call: c.eth_getTransactionReceipt
144
- }), this.getTransactionCount = this.buildRequest({
145
- call: c.eth_getTransactionCount,
146
- formatters: [null, h.defaultBlockParam]
147
- }), this.getGasPrice = this.buildRequest({
148
- call: c.eth_gasPrice
149
- }), this.getEstimateGas = (s) => this.buildRequest({
150
- call: c.eth_estimateGas
151
- })([s]), this.setSafeSettings = this.buildRequest({
152
- call: c.safe_setSettings
153
- });
154
- }
155
- buildRequest(e) {
156
- const { call: s, formatters: a } = e;
157
- return async (n) => {
158
- a && Array.isArray(n) && a.forEach((l, u) => {
159
- l && (n[u] = l(n[u]));
160
- });
161
- const i = {
162
- call: s,
163
- params: n || []
164
- };
165
- return (await this.communicator.send(r.rpcCall, i)).data;
166
- };
167
- }
168
- }
169
- const x = "0x1626ba7e", O = "0x20c13b0b", f = 4001;
170
- class d extends Error {
171
- constructor(e, s, a) {
172
- super(e), this.code = s, this.data = a, Object.setPrototypeOf(this, d.prototype);
173
- }
174
- }
175
- class S {
176
- constructor(e) {
177
- this.communicator = e;
178
- }
179
- async getPermissions() {
180
- return (await this.communicator.send(r.wallet_getPermissions, void 0)).data;
181
- }
182
- async requestPermissions(e) {
183
- if (!this.isPermissionRequestValid(e))
184
- throw new d("Permissions request is invalid", f);
185
- try {
186
- return (await this.communicator.send(r.wallet_requestPermissions, e)).data;
187
- } catch {
188
- throw new d("Permissions rejected", f);
189
- }
190
- }
191
- isPermissionRequestValid(e) {
192
- return e.every((s) => typeof s == "object" ? Object.keys(s).every((a) => !!Object.values(m).includes(a)) : !1);
193
- }
194
- }
195
- const w = (t, e) => e.some((s) => s.parentCapability === t), V = () => (t, e, s) => {
196
- const a = s.value;
197
- return s.value = async function() {
198
- const n = new S(this.communicator);
199
- let i = await n.getPermissions();
200
- if (w(e, i) || (i = await n.requestPermissions([{ [e]: {} }])), !w(e, i))
201
- throw new d("Permissions rejected", f);
202
- return a.apply(this);
203
- }, s;
204
- };
205
- var M = function(t, e, s, a) {
206
- var n = arguments.length, i = n < 3 ? e : a === null ? a = Object.getOwnPropertyDescriptor(e, s) : a, o;
207
- if (typeof Reflect == "object" && typeof Reflect.decorate == "function") i = Reflect.decorate(t, e, s, a);
208
- else for (var l = t.length - 1; l >= 0; l--) (o = t[l]) && (i = (n < 3 ? o(i) : n > 3 ? o(e, s, i) : o(e, s)) || i);
209
- return n > 3 && i && Object.defineProperty(e, s, i), i;
210
- };
211
- class _ {
212
- constructor(e) {
213
- this.communicator = e;
214
- }
215
- async getChainInfo() {
216
- return (await this.communicator.send(r.getChainInfo, void 0)).data;
217
- }
218
- async getInfo() {
219
- return (await this.communicator.send(r.getSafeInfo, void 0)).data;
220
- }
221
- // There is a possibility that this method will change because we may add pagination to the endpoint
222
- async experimental_getBalances({ currency: e = "usd" } = {}) {
223
- return (await this.communicator.send(r.getSafeBalances, {
224
- currency: e
225
- })).data;
226
- }
227
- async check1271Signature(e, s = "0x") {
228
- const a = await this.getInfo(), n = y({
229
- abi: [
230
- {
231
- constant: !1,
232
- inputs: [
233
- {
234
- name: "_dataHash",
235
- type: "bytes32"
236
- },
237
- {
238
- name: "_signature",
239
- type: "bytes"
240
- }
241
- ],
242
- name: "isValidSignature",
243
- outputs: [
244
- {
245
- name: "",
246
- type: "bytes4"
247
- }
248
- ],
249
- payable: !1,
250
- stateMutability: "nonpayable",
251
- type: "function"
252
- }
253
- ],
254
- functionName: "isValidSignature",
255
- args: [e, s]
256
- }), i = {
257
- call: c.eth_call,
258
- params: [
259
- {
260
- to: a.safeAddress,
261
- data: n
262
- },
263
- "latest"
264
- ]
265
- };
266
- try {
267
- return (await this.communicator.send(r.rpcCall, i)).data.slice(0, 10).toLowerCase() === x;
268
- } catch {
269
- return !1;
270
- }
271
- }
272
- async check1271SignatureBytes(e, s = "0x") {
273
- const a = await this.getInfo(), n = y({
274
- abi: [
275
- {
276
- constant: !1,
277
- inputs: [
278
- {
279
- name: "_data",
280
- type: "bytes"
281
- },
282
- {
283
- name: "_signature",
284
- type: "bytes"
285
- }
286
- ],
287
- name: "isValidSignature",
288
- outputs: [
289
- {
290
- name: "",
291
- type: "bytes4"
292
- }
293
- ],
294
- payable: !1,
295
- stateMutability: "nonpayable",
296
- type: "function"
297
- }
298
- ],
299
- functionName: "isValidSignature",
300
- args: [e, s]
301
- }), i = {
302
- call: c.eth_call,
303
- params: [
304
- {
305
- to: a.safeAddress,
306
- data: n
307
- },
308
- "latest"
309
- ]
310
- };
311
- try {
312
- return (await this.communicator.send(r.rpcCall, i)).data.slice(0, 10).toLowerCase() === O;
313
- } catch {
314
- return !1;
315
- }
316
- }
317
- calculateMessageHash(e) {
318
- return k(e);
319
- }
320
- calculateTypedMessageHash(e) {
321
- const s = typeof e.domain.chainId == "object" ? e.domain.chainId.toNumber() : Number(e.domain.chainId);
322
- let a = e.primaryType;
323
- if (!a) {
324
- const n = Object.values(e.types), i = Object.keys(e.types).filter((o) => n.every((l) => l.every(({ type: u }) => u.replace("[", "").replace("]", "") !== o)));
325
- if (i.length === 0 || i.length > 1)
326
- throw new Error("Please specify primaryType");
327
- a = i[0];
328
- }
329
- return I({
330
- message: e.message,
331
- domain: {
332
- ...e.domain,
333
- chainId: s,
334
- verifyingContract: e.domain.verifyingContract,
335
- salt: e.domain.salt
336
- },
337
- types: e.types,
338
- primaryType: a
339
- });
340
- }
341
- async getOffChainSignature(e) {
342
- return (await this.communicator.send(r.getOffChainSignature, e)).data;
343
- }
344
- async isMessageSigned(e, s = "0x") {
345
- let a;
346
- if (typeof e == "string" && (a = async () => {
347
- const n = this.calculateMessageHash(e);
348
- return await this.isMessageHashSigned(n, s);
349
- }), b(e) && (a = async () => {
350
- const n = this.calculateTypedMessageHash(e);
351
- return await this.isMessageHashSigned(n, s);
352
- }), a)
353
- return await a();
354
- throw new Error("Invalid message type");
355
- }
356
- async isMessageHashSigned(e, s = "0x") {
357
- const a = [this.check1271Signature.bind(this), this.check1271SignatureBytes.bind(this)];
358
- for (const n of a)
359
- if (await n(e, s))
360
- return !0;
361
- return !1;
362
- }
363
- async getEnvironmentInfo() {
364
- return (await this.communicator.send(r.getEnvironmentInfo, void 0)).data;
365
- }
366
- async requestAddressBook() {
367
- return (await this.communicator.send(r.requestAddressBook, void 0)).data;
368
- }
369
- }
370
- M([
371
- V()
372
- ], _.prototype, "requestAddressBook", null);
373
- class L {
374
- constructor(e = {}) {
375
- const { allowedDomains: s = null, debug: a = !1 } = e;
376
- this.communicator = new H(s, a), this.eth = new A(this.communicator), this.txs = new E(this.communicator), this.safe = new _(this.communicator), this.wallet = new S(this.communicator);
377
- }
378
- }
379
- export {
380
- g as MessageFormatter,
381
- r as Methods,
382
- c as RPC_CALLS,
383
- m as RestrictedMethods,
384
- L as default,
385
- q as getSDKVersion,
386
- b as isObjectEIP712TypedData
387
- };