@directcryptopay/sdk 0.2.3 → 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.
- package/README.md +51 -87
- package/dist/core/config.d.ts +9 -46
- package/dist/core/iframe.d.ts +16 -0
- package/dist/dcp-sdk.umd.js +1 -12811
- package/dist/dcp.d.ts +12 -5
- package/dist/index.d.ts +1 -1
- package/dist/index.js +219 -2
- package/dist/types.d.ts +26 -164
- package/package.json +3 -13
- package/dist/ExchangeController-CPMQq6Q-.js +0 -217
- package/dist/HelpersUtil-DfMFC7Bf.js +0 -120
- package/dist/NavigationUtil-kj9LEOOd.js +0 -8
- package/dist/PhArrowCircleDown-lsK25DCk.js +0 -73
- package/dist/PhArrowClockwise-NeKHZ1co.js +0 -73
- package/dist/PhArrowDown-C9AkNvLs.js +0 -73
- package/dist/PhArrowLeft-RNfIQP1X.js +0 -73
- package/dist/PhArrowRight-DM1tna0G.js +0 -73
- package/dist/PhArrowSquareOut-S5XYbAZj.js +0 -73
- package/dist/PhArrowUp-DmktzOWy.js +0 -73
- package/dist/PhArrowUpRight-BkNeW_5i.js +0 -73
- package/dist/PhArrowsClockwise-CQ4pG76b.js +0 -73
- package/dist/PhArrowsDownUp-H6gxaNM6.js +0 -73
- package/dist/PhArrowsLeftRight-DZSsfMR6.js +0 -73
- package/dist/PhBank-4_9QzqIB.js +0 -73
- package/dist/PhBrowser-B-JSznId.js +0 -73
- package/dist/PhCaretDown-vV5oHMNi.js +0 -73
- package/dist/PhCaretLeft-BLo6Y_f4.js +0 -73
- package/dist/PhCaretRight-CqQN4TT3.js +0 -73
- package/dist/PhCaretUp-Df7UCAHy.js +0 -73
- package/dist/PhCheck-gtpfK4ed.js +0 -73
- package/dist/PhCircleHalf-Uq7dwDYw.js +0 -73
- package/dist/PhClock-SDCW-NmF.js +0 -73
- package/dist/PhCompass-B7hgtdx-.js +0 -73
- package/dist/PhCopy-BcnhyXCy.js +0 -73
- package/dist/PhCreditCard-BJjByVgu.js +0 -73
- package/dist/PhCurrencyDollar-B7ZXqXBy.js +0 -73
- package/dist/PhDesktop-B3VKPuJx.js +0 -73
- package/dist/PhDeviceMobile-Bnd0TYEH.js +0 -73
- package/dist/PhDotsThree-yyMWyZ-R.js +0 -73
- package/dist/PhEnvelope-67uzHbI9.js +0 -73
- package/dist/PhFunnelSimple-B-DCsloI.js +0 -73
- package/dist/PhGlobe-TMm_6qGk.js +0 -73
- package/dist/PhIdentificationCard-CePPD2xc.js +0 -73
- package/dist/PhImage-gY96WtHR.js +0 -73
- package/dist/PhInfo-DRQM_ZDP.js +0 -73
- package/dist/PhLightbulb-B0TxPfZ1.js +0 -73
- package/dist/PhMagnifyingGlass-B8si5_6W.js +0 -73
- package/dist/PhPaperPlaneRight-DVu5PLYd.js +0 -73
- package/dist/PhPlus-BfTsQnUz.js +0 -73
- package/dist/PhPower-CxYUGOWn.js +0 -73
- package/dist/PhPuzzlePiece-CQ4wh0gV.js +0 -73
- package/dist/PhQrCode-BuJ97NYJ.js +0 -73
- package/dist/PhQuestion-kJoP8Mja.js +0 -73
- package/dist/PhQuestionMark-C46ZkFpu.js +0 -73
- package/dist/PhSealCheck-Eh8jVqSN.js +0 -73
- package/dist/PhSignOut-jk97OSVt.js +0 -73
- package/dist/PhSpinner-CiYOhwMg.js +0 -73
- package/dist/PhTrash-pxerMqzd.js +0 -73
- package/dist/PhUser-BMg0VV4A.js +0 -73
- package/dist/PhVault-DYQvx5A-.js +0 -73
- package/dist/PhWarning-NLC5Mj87.js +0 -73
- package/dist/PhWarningCircle-Ch2jU9fA.js +0 -73
- package/dist/PhX-Bx4wpwm3.js +0 -73
- package/dist/SwapController-Cti0Cyxa.js +0 -457
- package/dist/ccip-CKZd2XJ7.js +0 -150
- package/dist/core/api.d.ts +0 -39
- package/dist/core/logic.d.ts +0 -2
- package/dist/core/wallet.d.ts +0 -55
- package/dist/data-capture-7D5CL385.js +0 -490
- package/dist/email-AmK0INbZ.js +0 -344
- package/dist/embedded-wallet-Pn0I_XLn.js +0 -820
- package/dist/features-x8XNprEe.js +0 -274
- package/dist/hashTypedData-B50-z0AA.js +0 -197
- package/dist/if-defined-CdZSZ6UL.js +0 -10
- package/dist/index-4ewUtPPp.js +0 -7981
- package/dist/index-51l86yqx.js +0 -276
- package/dist/index-B6K56LF_.js +0 -85
- package/dist/index-BAmv9PxJ.js +0 -257
- package/dist/index-BEswjY9r.js +0 -117
- package/dist/index-BSKRq56S.js +0 -355
- package/dist/index-BaygXQxx.js +0 -172
- package/dist/index-BcPxaHr5.js +0 -118
- package/dist/index-Bjt7nGaJ.js +0 -199
- package/dist/index-BkTSyAJb.js +0 -21991
- package/dist/index-Bmnl7l2U.js +0 -555
- package/dist/index-BvPvouSq.js +0 -56
- package/dist/index-C-6iznUO.js +0 -174
- package/dist/index-C1QEJL-2.js +0 -572
- package/dist/index-C4M5s_AM.js +0 -228
- package/dist/index-CEqcN8QP.js +0 -1175
- package/dist/index-CM3YaYca.js +0 -8189
- package/dist/index-CclBLA5r.js +0 -517
- package/dist/index-ChTxJOiF.js +0 -46
- package/dist/index-CmAv0Tzr.js +0 -86
- package/dist/index-CmvoKY4x.js +0 -125
- package/dist/index-D7PmdQ9B.js +0 -1750
- package/dist/index-D7k2Pc4e.js +0 -1083
- package/dist/index-D7lmgqUR.js +0 -153
- package/dist/index-DG_-qYze.js +0 -107
- package/dist/index-DHot9Fdb.js +0 -218
- package/dist/index-DV2LrPtU.js +0 -123
- package/dist/index-DYBaJQ2W.js +0 -65
- package/dist/index-D_8VUmn1.js +0 -41543
- package/dist/index-D_gLn3rT.js +0 -100
- package/dist/index-DqcVUSC9.js +0 -62
- package/dist/index-I7VDqINw.js +0 -128
- package/dist/index-Oz72I9VP.js +0 -209
- package/dist/index-UclsHkJ0.js +0 -118
- package/dist/index-X8zir_1j.js +0 -110
- package/dist/index-XvlWKGCu.js +0 -1281
- package/dist/index-dO97xPlt.js +0 -171
- package/dist/index-uBeF6OAB.js +0 -387
- package/dist/index-zeA_RiCV.js +0 -159
- package/dist/localBatchGatewayRequest-BUZHGdjw.js +0 -91
- package/dist/onramp-CdnBuF0r.js +0 -855
- package/dist/parseSignature-CcyTNGr4.js +0 -3304
- package/dist/pay-with-exchange-CSM6WCOV.js +0 -525
- package/dist/property-Bd8U3_QP.js +0 -618
- package/dist/receive-DooMu4Dx.js +0 -232
- package/dist/ref-CpgjXAw7.js +0 -107
- package/dist/send-3T7CyYic.js +0 -1166
- package/dist/socials-Dt-iHL17.js +0 -620
- package/dist/swaps-CjA9Es42.js +0 -1760
- package/dist/transactions-nRm9DVzn.js +0 -37
- package/dist/ui/Modal.d.ts +0 -9
- package/dist/ui/index.d.ts +0 -6
- package/dist/w3m-modal-NV25AXhM.js +0 -1706
package/dist/index-dO97xPlt.js
DELETED
|
@@ -1,171 +0,0 @@
|
|
|
1
|
-
import { c_ as h, cX as p, cM as c, cY as a, cF as x, d3 as b, cE as g, d4 as v, d0 as C, cU as m, cV as _, cW as $ } from "./index-D_8VUmn1.js";
|
|
2
|
-
import { c as w, r as T } from "./index-CEqcN8QP.js";
|
|
3
|
-
import "./index-X8zir_1j.js";
|
|
4
|
-
const R = h``;
|
|
5
|
-
var O = function(n, e, r, o) {
|
|
6
|
-
var i = arguments.length, t = i < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, r) : o, s;
|
|
7
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") t = Reflect.decorate(n, e, r, o);
|
|
8
|
-
else for (var l = n.length - 1; l >= 0; l--) (s = n[l]) && (t = (i < 3 ? s(t) : i > 3 ? s(e, r, t) : s(e, r)) || t);
|
|
9
|
-
return i > 3 && t && Object.defineProperty(e, r, t), t;
|
|
10
|
-
};
|
|
11
|
-
let f = class extends p {
|
|
12
|
-
render() {
|
|
13
|
-
const { termsConditionsUrl: e, privacyPolicyUrl: r } = c.state;
|
|
14
|
-
return !e && !r ? null : a`
|
|
15
|
-
<wui-flex
|
|
16
|
-
.padding=${["4", "3", "3", "3"]}
|
|
17
|
-
flexDirection="column"
|
|
18
|
-
alignItems="center"
|
|
19
|
-
justifyContent="center"
|
|
20
|
-
gap="3"
|
|
21
|
-
>
|
|
22
|
-
<wui-text color="secondary" variant="md-regular" align="center">
|
|
23
|
-
We work with the best providers to give you the lowest fees and best support. More options
|
|
24
|
-
coming soon!
|
|
25
|
-
</wui-text>
|
|
26
|
-
|
|
27
|
-
${this.howDoesItWorkTemplate()}
|
|
28
|
-
</wui-flex>
|
|
29
|
-
`;
|
|
30
|
-
}
|
|
31
|
-
howDoesItWorkTemplate() {
|
|
32
|
-
return a` <wui-link @click=${this.onWhatIsBuy.bind(this)}>
|
|
33
|
-
<wui-icon size="xs" color="accent-primary" slot="iconLeft" name="helpCircle"></wui-icon>
|
|
34
|
-
How does it work?
|
|
35
|
-
</wui-link>`;
|
|
36
|
-
}
|
|
37
|
-
onWhatIsBuy() {
|
|
38
|
-
x.sendEvent({
|
|
39
|
-
type: "track",
|
|
40
|
-
event: "SELECT_WHAT_IS_A_BUY",
|
|
41
|
-
properties: {
|
|
42
|
-
isSmartAccount: b(g.state.activeChain) === v.ACCOUNT_TYPES.SMART_ACCOUNT
|
|
43
|
-
}
|
|
44
|
-
}), C.push("WhatIsABuy");
|
|
45
|
-
}
|
|
46
|
-
};
|
|
47
|
-
f.styles = [R];
|
|
48
|
-
f = O([
|
|
49
|
-
w("w3m-onramp-providers-footer")
|
|
50
|
-
], f);
|
|
51
|
-
const P = "https://reown.com", U = m`
|
|
52
|
-
.reown-logo {
|
|
53
|
-
height: 24px;
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
a {
|
|
57
|
-
text-decoration: none;
|
|
58
|
-
cursor: pointer;
|
|
59
|
-
color: ${({ tokens: n }) => n.theme.textSecondary};
|
|
60
|
-
}
|
|
61
|
-
|
|
62
|
-
a:hover {
|
|
63
|
-
opacity: 0.9;
|
|
64
|
-
}
|
|
65
|
-
`;
|
|
66
|
-
var W = function(n, e, r, o) {
|
|
67
|
-
var i = arguments.length, t = i < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, r) : o, s;
|
|
68
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") t = Reflect.decorate(n, e, r, o);
|
|
69
|
-
else for (var l = n.length - 1; l >= 0; l--) (s = n[l]) && (t = (i < 3 ? s(t) : i > 3 ? s(e, r, t) : s(e, r)) || t);
|
|
70
|
-
return i > 3 && t && Object.defineProperty(e, r, t), t;
|
|
71
|
-
};
|
|
72
|
-
let d = class extends p {
|
|
73
|
-
render() {
|
|
74
|
-
return a`
|
|
75
|
-
<a
|
|
76
|
-
data-testid="ux-branding-reown"
|
|
77
|
-
href=${P}
|
|
78
|
-
rel="noreferrer"
|
|
79
|
-
target="_blank"
|
|
80
|
-
style="text-decoration: none;"
|
|
81
|
-
>
|
|
82
|
-
<wui-flex
|
|
83
|
-
justifyContent="center"
|
|
84
|
-
alignItems="center"
|
|
85
|
-
gap="1"
|
|
86
|
-
.padding=${["01", "0", "3", "0"]}
|
|
87
|
-
>
|
|
88
|
-
<wui-text variant="sm-regular" color="inherit"> UX by </wui-text>
|
|
89
|
-
<wui-icon name="reown" size="inherit" class="reown-logo"></wui-icon>
|
|
90
|
-
</wui-flex>
|
|
91
|
-
</a>
|
|
92
|
-
`;
|
|
93
|
-
}
|
|
94
|
-
};
|
|
95
|
-
d.styles = [_, $, U];
|
|
96
|
-
d = W([
|
|
97
|
-
w("wui-ux-by-reown")
|
|
98
|
-
], d);
|
|
99
|
-
const B = m`
|
|
100
|
-
:host wui-ux-by-reown {
|
|
101
|
-
padding-top: 0;
|
|
102
|
-
}
|
|
103
|
-
|
|
104
|
-
:host wui-ux-by-reown.branding-only {
|
|
105
|
-
padding-top: ${({ spacing: n }) => n[3]};
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
a {
|
|
109
|
-
text-decoration: none;
|
|
110
|
-
color: ${({ tokens: n }) => n.core.textAccentPrimary};
|
|
111
|
-
font-weight: 500;
|
|
112
|
-
}
|
|
113
|
-
`;
|
|
114
|
-
var y = function(n, e, r, o) {
|
|
115
|
-
var i = arguments.length, t = i < 3 ? e : o === null ? o = Object.getOwnPropertyDescriptor(e, r) : o, s;
|
|
116
|
-
if (typeof Reflect == "object" && typeof Reflect.decorate == "function") t = Reflect.decorate(n, e, r, o);
|
|
117
|
-
else for (var l = n.length - 1; l >= 0; l--) (s = n[l]) && (t = (i < 3 ? s(t) : i > 3 ? s(e, r, t) : s(e, r)) || t);
|
|
118
|
-
return i > 3 && t && Object.defineProperty(e, r, t), t;
|
|
119
|
-
};
|
|
120
|
-
let u = class extends p {
|
|
121
|
-
constructor() {
|
|
122
|
-
super(), this.unsubscribe = [], this.remoteFeatures = c.state.remoteFeatures, this.unsubscribe.push(c.subscribeKey("remoteFeatures", (e) => this.remoteFeatures = e));
|
|
123
|
-
}
|
|
124
|
-
disconnectedCallback() {
|
|
125
|
-
this.unsubscribe.forEach((e) => e());
|
|
126
|
-
}
|
|
127
|
-
render() {
|
|
128
|
-
var t;
|
|
129
|
-
const { termsConditionsUrl: e, privacyPolicyUrl: r } = c.state, o = (t = c.state.features) == null ? void 0 : t.legalCheckbox;
|
|
130
|
-
return !e && !r || o ? a`
|
|
131
|
-
<wui-flex flexDirection="column"> ${this.reownBrandingTemplate(!0)} </wui-flex>
|
|
132
|
-
` : a`
|
|
133
|
-
<wui-flex flexDirection="column">
|
|
134
|
-
<wui-flex .padding=${["4", "3", "3", "3"]} justifyContent="center">
|
|
135
|
-
<wui-text color="secondary" variant="md-regular" align="center">
|
|
136
|
-
By connecting your wallet, you agree to our <br />
|
|
137
|
-
${this.termsTemplate()} ${this.andTemplate()} ${this.privacyTemplate()}
|
|
138
|
-
</wui-text>
|
|
139
|
-
</wui-flex>
|
|
140
|
-
${this.reownBrandingTemplate()}
|
|
141
|
-
</wui-flex>
|
|
142
|
-
`;
|
|
143
|
-
}
|
|
144
|
-
andTemplate() {
|
|
145
|
-
const { termsConditionsUrl: e, privacyPolicyUrl: r } = c.state;
|
|
146
|
-
return e && r ? "and" : "";
|
|
147
|
-
}
|
|
148
|
-
termsTemplate() {
|
|
149
|
-
const { termsConditionsUrl: e } = c.state;
|
|
150
|
-
return e ? a`<a href=${e} target="_blank" rel="noopener noreferrer"
|
|
151
|
-
>Terms of Service</a
|
|
152
|
-
>` : null;
|
|
153
|
-
}
|
|
154
|
-
privacyTemplate() {
|
|
155
|
-
const { privacyPolicyUrl: e } = c.state;
|
|
156
|
-
return e ? a`<a href=${e} target="_blank" rel="noopener noreferrer"
|
|
157
|
-
>Privacy Policy</a
|
|
158
|
-
>` : null;
|
|
159
|
-
}
|
|
160
|
-
reownBrandingTemplate(e = !1) {
|
|
161
|
-
var r;
|
|
162
|
-
return (r = this.remoteFeatures) != null && r.reownBranding ? e ? a`<wui-ux-by-reown class="branding-only"></wui-ux-by-reown>` : a`<wui-ux-by-reown></wui-ux-by-reown>` : null;
|
|
163
|
-
}
|
|
164
|
-
};
|
|
165
|
-
u.styles = [B];
|
|
166
|
-
y([
|
|
167
|
-
T()
|
|
168
|
-
], u.prototype, "remoteFeatures", void 0);
|
|
169
|
-
u = y([
|
|
170
|
-
w("w3m-legal-footer")
|
|
171
|
-
], u);
|
package/dist/index-uBeF6OAB.js
DELETED
|
@@ -1,387 +0,0 @@
|
|
|
1
|
-
import { r as T } from "./index-C1QEJL-2.js";
|
|
2
|
-
import { bk as y } from "./index-D_8VUmn1.js";
|
|
3
|
-
import { h as k, e as I } from "./hashTypedData-B50-z0AA.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
|
-
};
|