@crossmint/wallets-sdk 0.18.3 → 0.18.6
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/dist/api/client.cjs +10 -1
- package/dist/api/client.js +10 -1
- package/dist/api/gen/client.gen.cjs +7 -1
- package/dist/api/gen/client.gen.js +7 -1
- package/dist/api/gen/index.cjs +179 -1
- package/dist/api/gen/index.js +179 -1
- package/dist/api/gen/sdk.gen.cjs +178 -1
- package/dist/api/gen/sdk.gen.js +178 -1
- package/dist/api/gen/types.gen.js +1 -1
- package/dist/api/index.cjs +12 -1
- package/dist/api/index.js +12 -1
- package/dist/api/types.js +1 -1
- package/dist/chains/chains.cjs +9 -1
- package/dist/chains/chains.js +9 -1
- package/dist/chains/definitions/story.cjs +7 -1
- package/dist/chains/definitions/story.js +7 -1
- package/dist/chains/definitions/storyTestnet.cjs +7 -1
- package/dist/chains/definitions/storyTestnet.js +7 -1
- package/dist/chunk-2T5HHKUI.js +19 -0
- package/dist/chunk-34FDYDOM.cjs +87 -0
- package/dist/chunk-3U6UAYOV.js +25 -0
- package/dist/chunk-454RYNSZ.js +80 -0
- package/dist/chunk-455NK5LB.js +0 -0
- package/dist/chunk-55V4VMTX.cjs +25 -0
- package/dist/chunk-5BP6CVYY.cjs +58 -0
- package/dist/chunk-5YR2ILEW.js +69 -0
- package/dist/chunk-6G7ZWCCG.js +247 -0
- package/dist/chunk-7ECQJFYM.cjs +63 -0
- package/dist/chunk-7JFVG4IY.js +59 -0
- package/dist/chunk-AL77JANE.js +36 -0
- package/dist/chunk-B6JOIWRH.cjs +289 -0
- package/dist/chunk-BSC55MYK.cjs +43 -0
- package/dist/chunk-CCIGWTAO.cjs +1 -0
- package/dist/chunk-CHGPNMRL.cjs +36 -0
- package/dist/chunk-CL44FTXR.js +289 -0
- package/dist/chunk-CN2GVFBU.cjs +138 -0
- package/dist/chunk-DQCXGBZM.js +59 -0
- package/dist/chunk-E3OS753T.js +175 -0
- package/dist/chunk-EYJQSDDI.js +43 -0
- package/dist/chunk-F6E3ZDRG.cjs +175 -0
- package/dist/chunk-FPMW7Q5O.js +55 -0
- package/dist/chunk-G3LEJR3P.cjs +53 -0
- package/dist/chunk-G5NYLGM5.cjs +55 -0
- package/dist/chunk-GLRDLJS5.js +92 -0
- package/dist/chunk-GNF2U7IX.cjs +69 -0
- package/dist/chunk-GQIZWD4F.cjs +301 -0
- package/dist/chunk-HYKMSBCT.cjs +75 -0
- package/dist/chunk-IVNYZDI5.cjs +73 -0
- package/dist/chunk-K3HFAPSV.js +73 -0
- package/dist/chunk-KS63YEQ4.js +138 -0
- package/dist/chunk-KT3CVXFG.js +9 -0
- package/dist/chunk-LGONZW4W.cjs +629 -0
- package/dist/chunk-LHYSCUKJ.cjs +16 -0
- package/dist/chunk-LKAO2MV2.cjs +80 -0
- package/dist/chunk-LLFD22UQ.cjs +36 -0
- package/dist/chunk-MZBFXUHT.js +63 -0
- package/dist/chunk-NIBKCMQ2.cjs +19 -0
- package/dist/chunk-OKXSUK63.js +87 -0
- package/dist/chunk-R2OY54EJ.cjs +59 -0
- package/dist/chunk-RAWKXOHR.js +53 -0
- package/dist/chunk-RBHGZDDX.cjs +58 -0
- package/dist/chunk-RHR6P2KP.cjs +15 -0
- package/dist/chunk-RTRDZB52.js +778 -0
- package/dist/chunk-S5YXROL6.js +301 -0
- package/dist/chunk-SGINWAB6.js +155 -0
- package/dist/chunk-TK3EUCQ4.cjs +59 -0
- package/dist/chunk-TOHXQVLS.js +58 -0
- package/dist/chunk-UKBWSQ7R.js +629 -0
- package/dist/chunk-UMGB3Q7I.cjs +92 -0
- package/dist/chunk-V3QJQUT7.cjs +778 -0
- package/dist/chunk-WC7T2CR4.js +44 -0
- package/dist/chunk-WJUPOCKJ.js +15 -0
- package/dist/chunk-WQVJM3PG.js +16 -0
- package/dist/chunk-XC2V34TS.cjs +155 -0
- package/dist/chunk-XRA5GFH3.js +75 -0
- package/dist/chunk-YBA7WO32.cjs +44 -0
- package/dist/chunk-ZP4ZZCIE.js +58 -0
- package/dist/chunk-ZT7EGOCI.cjs +9 -0
- package/dist/chunk-ZTGRDOOH.js +36 -0
- package/dist/chunk-ZZJ7U5G3.cjs +247 -0
- package/dist/index.cjs +57 -1
- package/dist/index.js +57 -1
- package/dist/logger/index.cjs +11 -0
- package/dist/logger/index.d.cts +2 -0
- package/dist/logger/index.d.ts +2 -0
- package/dist/logger/index.js +11 -0
- package/dist/logger/init.cjs +10 -0
- package/dist/logger/init.d.cts +15 -0
- package/dist/logger/init.d.ts +15 -0
- package/dist/logger/init.js +10 -0
- package/dist/sdk.cjs +33 -1
- package/dist/sdk.js +33 -1
- package/dist/signers/evm-api-key.cjs +7 -1
- package/dist/signers/evm-api-key.js +7 -1
- package/dist/signers/evm-external-wallet.cjs +7 -1
- package/dist/signers/evm-external-wallet.js +7 -1
- package/dist/signers/index.cjs +21 -1
- package/dist/signers/index.js +21 -1
- package/dist/signers/non-custodial/index.cjs +24 -1
- package/dist/signers/non-custodial/index.js +24 -1
- package/dist/signers/non-custodial/ncs-evm-signer.cjs +10 -1
- package/dist/signers/non-custodial/ncs-evm-signer.js +10 -1
- package/dist/signers/non-custodial/ncs-iframe-manager.cjs +7 -1
- package/dist/signers/non-custodial/ncs-iframe-manager.js +7 -1
- package/dist/signers/non-custodial/ncs-signer.cjs +11 -1
- package/dist/signers/non-custodial/ncs-signer.js +11 -1
- package/dist/signers/non-custodial/ncs-solana-signer.cjs +10 -1
- package/dist/signers/non-custodial/ncs-solana-signer.js +10 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.cjs +10 -1
- package/dist/signers/non-custodial/ncs-stellar-signer.js +10 -1
- package/dist/signers/passkey.cjs +7 -1
- package/dist/signers/passkey.js +7 -1
- package/dist/signers/solana-api-key.cjs +7 -1
- package/dist/signers/solana-api-key.js +7 -1
- package/dist/signers/solana-external-wallet.cjs +8 -1
- package/dist/signers/solana-external-wallet.js +8 -1
- package/dist/signers/stellar-external-wallet.cjs +7 -1
- package/dist/signers/stellar-external-wallet.js +7 -1
- package/dist/signers/types.cjs +9 -1
- package/dist/signers/types.js +9 -1
- package/dist/utils/constants.cjs +13 -1
- package/dist/utils/constants.js +13 -1
- package/dist/utils/errors.cjs +55 -1
- package/dist/utils/errors.js +55 -1
- package/dist/utils/signer-validation.cjs +10 -1
- package/dist/utils/signer-validation.d.cts +7 -1
- package/dist/utils/signer-validation.d.ts +7 -1
- package/dist/utils/signer-validation.js +10 -1
- package/dist/wallets/evm.cjs +20 -1
- package/dist/wallets/evm.js +20 -1
- package/dist/wallets/solana.cjs +18 -1
- package/dist/wallets/solana.js +18 -1
- package/dist/wallets/stellar.cjs +17 -1
- package/dist/wallets/stellar.js +17 -1
- package/dist/wallets/wallet-factory.cjs +27 -1
- package/dist/wallets/wallet-factory.js +27 -1
- package/dist/wallets/wallet.cjs +16 -1
- package/dist/wallets/wallet.js +16 -1
- package/package.json +6 -5
- package/dist/chunk-2SHDBC47.js +0 -1
- package/dist/chunk-2XVV7Z43.cjs +0 -1
- package/dist/chunk-2YH3NVVK.cjs +0 -1
- package/dist/chunk-3APSOOE3.js +0 -1
- package/dist/chunk-3SW6AJSG.cjs +0 -1
- package/dist/chunk-4KXOWU5E.cjs +0 -1
- package/dist/chunk-5M7IRODB.js +0 -1
- package/dist/chunk-5QIW67NU.cjs +0 -1
- package/dist/chunk-6PVKL5RC.js +0 -1
- package/dist/chunk-7HTB7WKD.cjs +0 -1
- package/dist/chunk-7JIPYRKX.js +0 -1
- package/dist/chunk-BQZES4ST.js +0 -1
- package/dist/chunk-BW7YYVZE.js +0 -1
- package/dist/chunk-C3T63EC7.cjs +0 -1
- package/dist/chunk-CXTC3YDL.cjs +0 -1
- package/dist/chunk-DV6ZRFKV.js +0 -1
- package/dist/chunk-DX7VVXY5.cjs +0 -1
- package/dist/chunk-FATVK26C.js +0 -1
- package/dist/chunk-GEY574TH.cjs +0 -1
- package/dist/chunk-GKZFI322.js +0 -1
- package/dist/chunk-H4T4IXCF.js +0 -1
- package/dist/chunk-HJ5EDMTA.js +0 -1
- package/dist/chunk-HPHVJ6BA.cjs +0 -1
- package/dist/chunk-HQAKCIYM.js +0 -1
- package/dist/chunk-HRSVFJND.cjs +0 -1
- package/dist/chunk-IGBQEAD5.js +0 -1
- package/dist/chunk-IR5WN6FQ.cjs +0 -1
- package/dist/chunk-JUSY5XEE.js +0 -1
- package/dist/chunk-KFJLRIY7.js +0 -1
- package/dist/chunk-KKQBZXFE.js +0 -1
- package/dist/chunk-KO6QYKDX.cjs +0 -1
- package/dist/chunk-KRV3IXJU.cjs +0 -1
- package/dist/chunk-LW6JSI4J.js +0 -1
- package/dist/chunk-M2UBZY5S.cjs +0 -1
- package/dist/chunk-M4TOGGLV.cjs +0 -1
- package/dist/chunk-MQP5VZCA.cjs +0 -1
- package/dist/chunk-NP32UO2G.cjs +0 -1
- package/dist/chunk-O4FVTK7X.cjs +0 -1
- package/dist/chunk-P6JJHAAV.js +0 -1
- package/dist/chunk-PONCGT2H.cjs +0 -1
- package/dist/chunk-PSXRNSOE.js +0 -1
- package/dist/chunk-QMXG67T3.cjs +0 -1
- package/dist/chunk-RJZV72YF.js +0 -1
- package/dist/chunk-S3DYQVRD.js +0 -1
- package/dist/chunk-SLG7HGGL.js +0 -1
- package/dist/chunk-STYSP6KL.cjs +0 -1
- package/dist/chunk-UBOWSXW3.js +0 -1
- package/dist/chunk-UNBXKCNN.js +0 -1
- package/dist/chunk-VY634F3J.js +0 -1
- package/dist/chunk-WQP2FSVI.js +0 -1
- package/dist/chunk-WYYAPI4G.cjs +0 -1
- package/dist/chunk-WZFHEUWT.cjs +0 -1
- package/dist/chunk-XALFCQKD.cjs +0 -1
- package/dist/chunk-YWPTI2QO.cjs +0 -1
- package/dist/chunk-YWXQIFVZ.js +0 -3
- package/dist/chunk-YZ4HRYSL.cjs +0 -1
- package/dist/chunk-Z54LVUDS.js +0 -1
- package/dist/chunk-ZWMB3QLR.cjs +0 -3
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Wallet
|
|
3
|
+
} from "./chunk-UKBWSQ7R.js";
|
|
4
|
+
import {
|
|
5
|
+
InvalidTypedDataError,
|
|
6
|
+
SignatureNotCreatedError,
|
|
7
|
+
TransactionNotCreatedError
|
|
8
|
+
} from "./chunk-SGINWAB6.js";
|
|
9
|
+
import {
|
|
10
|
+
toViemChain
|
|
11
|
+
} from "./chunk-KS63YEQ4.js";
|
|
12
|
+
import {
|
|
13
|
+
__async
|
|
14
|
+
} from "./chunk-FPMW7Q5O.js";
|
|
15
|
+
|
|
16
|
+
// src/wallets/evm.ts
|
|
17
|
+
import { createPublicClient, encodeFunctionData, http } from "viem";
|
|
18
|
+
import { isValidEvmAddress } from "@crossmint/common-sdk-base";
|
|
19
|
+
var EVMWallet = class _EVMWallet extends Wallet {
|
|
20
|
+
constructor(wallet) {
|
|
21
|
+
super(
|
|
22
|
+
{
|
|
23
|
+
chain: wallet.chain,
|
|
24
|
+
address: wallet.address,
|
|
25
|
+
owner: wallet.owner,
|
|
26
|
+
signer: wallet.signer,
|
|
27
|
+
options: Wallet.getOptions(wallet),
|
|
28
|
+
alias: wallet.alias
|
|
29
|
+
},
|
|
30
|
+
Wallet.getApiClient(wallet)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
static from(wallet) {
|
|
34
|
+
if (!isValidEvmAddress(wallet.address)) {
|
|
35
|
+
throw new Error("Wallet is not an EVM wallet");
|
|
36
|
+
}
|
|
37
|
+
return new _EVMWallet(wallet);
|
|
38
|
+
}
|
|
39
|
+
sendTransaction(params) {
|
|
40
|
+
return __async(this, null, function* () {
|
|
41
|
+
var _a;
|
|
42
|
+
yield this.preAuthIfNeeded();
|
|
43
|
+
const builtTransaction = this.buildTransaction(params);
|
|
44
|
+
const createdTransaction = yield this.createTransaction(builtTransaction, params.options);
|
|
45
|
+
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
46
|
+
return {
|
|
47
|
+
hash: void 0,
|
|
48
|
+
explorerLink: void 0,
|
|
49
|
+
transactionId: createdTransaction.id
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return yield this.approveTransactionAndWait(createdTransaction.id);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
signMessage(params) {
|
|
56
|
+
return __async(this, null, function* () {
|
|
57
|
+
var _a;
|
|
58
|
+
yield this.preAuthIfNeeded();
|
|
59
|
+
const signatureCreationResponse = yield this.apiClient.createSignature(this.walletLocator, {
|
|
60
|
+
type: "message",
|
|
61
|
+
params: {
|
|
62
|
+
message: params.message,
|
|
63
|
+
signer: this.signer.locator(),
|
|
64
|
+
chain: this.chain
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if ("error" in signatureCreationResponse) {
|
|
68
|
+
throw new SignatureNotCreatedError(JSON.stringify(signatureCreationResponse));
|
|
69
|
+
}
|
|
70
|
+
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
71
|
+
return {
|
|
72
|
+
signature: void 0,
|
|
73
|
+
signatureId: signatureCreationResponse.id
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return yield this.approveSignatureAndWait(signatureCreationResponse.id);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
signTypedData(params) {
|
|
80
|
+
return __async(this, null, function* () {
|
|
81
|
+
var _a;
|
|
82
|
+
yield this.preAuthIfNeeded();
|
|
83
|
+
const { domain, message, primaryType, types, chain } = params;
|
|
84
|
+
if (!domain || !message || !types || !chain) {
|
|
85
|
+
throw new InvalidTypedDataError("Invalid typed data");
|
|
86
|
+
}
|
|
87
|
+
const { name, version, chainId, verifyingContract, salt } = domain;
|
|
88
|
+
if (!name || !version || !chainId || !verifyingContract) {
|
|
89
|
+
throw new InvalidTypedDataError("Invalid typed data domain");
|
|
90
|
+
}
|
|
91
|
+
const signatureCreationResponse = yield this.apiClient.createSignature(this.walletLocator, {
|
|
92
|
+
type: "typed-data",
|
|
93
|
+
params: {
|
|
94
|
+
typedData: {
|
|
95
|
+
domain: {
|
|
96
|
+
name,
|
|
97
|
+
version,
|
|
98
|
+
chainId: Number(chainId),
|
|
99
|
+
verifyingContract,
|
|
100
|
+
salt
|
|
101
|
+
},
|
|
102
|
+
message,
|
|
103
|
+
primaryType,
|
|
104
|
+
types
|
|
105
|
+
},
|
|
106
|
+
signer: this.signer.locator(),
|
|
107
|
+
chain
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if ("error" in signatureCreationResponse) {
|
|
111
|
+
throw new SignatureNotCreatedError(JSON.stringify(signatureCreationResponse));
|
|
112
|
+
}
|
|
113
|
+
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
114
|
+
return {
|
|
115
|
+
signature: void 0,
|
|
116
|
+
signatureId: signatureCreationResponse.id
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return yield this.approveSignatureAndWait(signatureCreationResponse.id);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
getViemClient(params) {
|
|
123
|
+
var _a;
|
|
124
|
+
return createPublicClient({
|
|
125
|
+
transport: (_a = params == null ? void 0 : params.transport) != null ? _a : http(),
|
|
126
|
+
chain: toViemChain(this.chain)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
createTransaction(transaction, options) {
|
|
130
|
+
return __async(this, null, function* () {
|
|
131
|
+
var _a;
|
|
132
|
+
const signer = (_a = options == null ? void 0 : options.experimental_signer) != null ? _a : this.signer.locator();
|
|
133
|
+
const transactionCreationResponse = yield this.apiClient.createTransaction(this.walletLocator, {
|
|
134
|
+
params: {
|
|
135
|
+
signer,
|
|
136
|
+
chain: this.chain,
|
|
137
|
+
calls: [transaction]
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
if ("error" in transactionCreationResponse) {
|
|
141
|
+
throw new TransactionNotCreatedError(JSON.stringify(transactionCreationResponse));
|
|
142
|
+
}
|
|
143
|
+
return transactionCreationResponse;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
buildTransaction(params) {
|
|
147
|
+
var _a, _b, _c, _d, _e;
|
|
148
|
+
if ("transaction" in params) {
|
|
149
|
+
return { transaction: params.transaction };
|
|
150
|
+
}
|
|
151
|
+
if (params.abi == null) {
|
|
152
|
+
return {
|
|
153
|
+
to: params.to,
|
|
154
|
+
value: (_b = (_a = params.value) == null ? void 0 : _a.toString()) != null ? _b : "0",
|
|
155
|
+
data: (_c = params.data) != null ? _c : "0x"
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (!params.functionName) {
|
|
159
|
+
throw new Error("Function name is required");
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
to: params.to,
|
|
163
|
+
value: (_e = (_d = params.value) == null ? void 0 : _d.toString()) != null ? _e : "0",
|
|
164
|
+
data: encodeFunctionData({
|
|
165
|
+
abi: params.abi,
|
|
166
|
+
functionName: params.functionName,
|
|
167
|
+
args: params.args
|
|
168
|
+
})
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
export {
|
|
174
|
+
EVMWallet
|
|
175
|
+
};
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__async
|
|
3
|
+
} from "./chunk-FPMW7Q5O.js";
|
|
4
|
+
|
|
5
|
+
// src/signers/passkey.ts
|
|
6
|
+
import { WebAuthnP256 } from "ox";
|
|
7
|
+
var PasskeySigner = class {
|
|
8
|
+
constructor(config) {
|
|
9
|
+
this.config = config;
|
|
10
|
+
this.type = "passkey";
|
|
11
|
+
this.id = config.id;
|
|
12
|
+
}
|
|
13
|
+
locator() {
|
|
14
|
+
return this.config.locator;
|
|
15
|
+
}
|
|
16
|
+
signMessage(message) {
|
|
17
|
+
return __async(this, null, function* () {
|
|
18
|
+
if (this.config.onSignWithPasskey) {
|
|
19
|
+
return yield this.config.onSignWithPasskey(message);
|
|
20
|
+
}
|
|
21
|
+
const { signature, metadata } = yield WebAuthnP256.sign({
|
|
22
|
+
credentialId: this.id,
|
|
23
|
+
challenge: message
|
|
24
|
+
});
|
|
25
|
+
return {
|
|
26
|
+
signature: {
|
|
27
|
+
r: `0x${signature.r.toString(16)}`,
|
|
28
|
+
s: `0x${signature.s.toString(16)}`
|
|
29
|
+
},
|
|
30
|
+
metadata
|
|
31
|
+
};
|
|
32
|
+
});
|
|
33
|
+
}
|
|
34
|
+
signTransaction(transaction) {
|
|
35
|
+
return __async(this, null, function* () {
|
|
36
|
+
return yield this.signMessage(transaction);
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
};
|
|
40
|
+
|
|
41
|
+
export {
|
|
42
|
+
PasskeySigner
|
|
43
|
+
};
|
|
@@ -0,0 +1,175 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkLGONZW4Wcjs = require('./chunk-LGONZW4W.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
var _chunkXC2V34TScjs = require('./chunk-XC2V34TS.cjs');
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
var _chunkCN2GVFBUcjs = require('./chunk-CN2GVFBU.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
|
|
15
|
+
|
|
16
|
+
// src/wallets/evm.ts
|
|
17
|
+
var _viem = require('viem');
|
|
18
|
+
var _commonsdkbase = require('@crossmint/common-sdk-base');
|
|
19
|
+
var EVMWallet = class _EVMWallet extends _chunkLGONZW4Wcjs.Wallet {
|
|
20
|
+
constructor(wallet) {
|
|
21
|
+
super(
|
|
22
|
+
{
|
|
23
|
+
chain: wallet.chain,
|
|
24
|
+
address: wallet.address,
|
|
25
|
+
owner: wallet.owner,
|
|
26
|
+
signer: wallet.signer,
|
|
27
|
+
options: _chunkLGONZW4Wcjs.Wallet.getOptions(wallet),
|
|
28
|
+
alias: wallet.alias
|
|
29
|
+
},
|
|
30
|
+
_chunkLGONZW4Wcjs.Wallet.getApiClient(wallet)
|
|
31
|
+
);
|
|
32
|
+
}
|
|
33
|
+
static from(wallet) {
|
|
34
|
+
if (!_commonsdkbase.isValidEvmAddress.call(void 0, wallet.address)) {
|
|
35
|
+
throw new Error("Wallet is not an EVM wallet");
|
|
36
|
+
}
|
|
37
|
+
return new _EVMWallet(wallet);
|
|
38
|
+
}
|
|
39
|
+
sendTransaction(params) {
|
|
40
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
41
|
+
var _a;
|
|
42
|
+
yield this.preAuthIfNeeded();
|
|
43
|
+
const builtTransaction = this.buildTransaction(params);
|
|
44
|
+
const createdTransaction = yield this.createTransaction(builtTransaction, params.options);
|
|
45
|
+
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
46
|
+
return {
|
|
47
|
+
hash: void 0,
|
|
48
|
+
explorerLink: void 0,
|
|
49
|
+
transactionId: createdTransaction.id
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
return yield this.approveTransactionAndWait(createdTransaction.id);
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
signMessage(params) {
|
|
56
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
57
|
+
var _a;
|
|
58
|
+
yield this.preAuthIfNeeded();
|
|
59
|
+
const signatureCreationResponse = yield this.apiClient.createSignature(this.walletLocator, {
|
|
60
|
+
type: "message",
|
|
61
|
+
params: {
|
|
62
|
+
message: params.message,
|
|
63
|
+
signer: this.signer.locator(),
|
|
64
|
+
chain: this.chain
|
|
65
|
+
}
|
|
66
|
+
});
|
|
67
|
+
if ("error" in signatureCreationResponse) {
|
|
68
|
+
throw new (0, _chunkXC2V34TScjs.SignatureNotCreatedError)(JSON.stringify(signatureCreationResponse));
|
|
69
|
+
}
|
|
70
|
+
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
71
|
+
return {
|
|
72
|
+
signature: void 0,
|
|
73
|
+
signatureId: signatureCreationResponse.id
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
return yield this.approveSignatureAndWait(signatureCreationResponse.id);
|
|
77
|
+
});
|
|
78
|
+
}
|
|
79
|
+
signTypedData(params) {
|
|
80
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
81
|
+
var _a;
|
|
82
|
+
yield this.preAuthIfNeeded();
|
|
83
|
+
const { domain, message, primaryType, types, chain } = params;
|
|
84
|
+
if (!domain || !message || !types || !chain) {
|
|
85
|
+
throw new (0, _chunkXC2V34TScjs.InvalidTypedDataError)("Invalid typed data");
|
|
86
|
+
}
|
|
87
|
+
const { name, version, chainId, verifyingContract, salt } = domain;
|
|
88
|
+
if (!name || !version || !chainId || !verifyingContract) {
|
|
89
|
+
throw new (0, _chunkXC2V34TScjs.InvalidTypedDataError)("Invalid typed data domain");
|
|
90
|
+
}
|
|
91
|
+
const signatureCreationResponse = yield this.apiClient.createSignature(this.walletLocator, {
|
|
92
|
+
type: "typed-data",
|
|
93
|
+
params: {
|
|
94
|
+
typedData: {
|
|
95
|
+
domain: {
|
|
96
|
+
name,
|
|
97
|
+
version,
|
|
98
|
+
chainId: Number(chainId),
|
|
99
|
+
verifyingContract,
|
|
100
|
+
salt
|
|
101
|
+
},
|
|
102
|
+
message,
|
|
103
|
+
primaryType,
|
|
104
|
+
types
|
|
105
|
+
},
|
|
106
|
+
signer: this.signer.locator(),
|
|
107
|
+
chain
|
|
108
|
+
}
|
|
109
|
+
});
|
|
110
|
+
if ("error" in signatureCreationResponse) {
|
|
111
|
+
throw new (0, _chunkXC2V34TScjs.SignatureNotCreatedError)(JSON.stringify(signatureCreationResponse));
|
|
112
|
+
}
|
|
113
|
+
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
114
|
+
return {
|
|
115
|
+
signature: void 0,
|
|
116
|
+
signatureId: signatureCreationResponse.id
|
|
117
|
+
};
|
|
118
|
+
}
|
|
119
|
+
return yield this.approveSignatureAndWait(signatureCreationResponse.id);
|
|
120
|
+
});
|
|
121
|
+
}
|
|
122
|
+
getViemClient(params) {
|
|
123
|
+
var _a;
|
|
124
|
+
return _viem.createPublicClient.call(void 0, {
|
|
125
|
+
transport: (_a = params == null ? void 0 : params.transport) != null ? _a : _viem.http.call(void 0, ),
|
|
126
|
+
chain: _chunkCN2GVFBUcjs.toViemChain.call(void 0, this.chain)
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
createTransaction(transaction, options) {
|
|
130
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
131
|
+
var _a;
|
|
132
|
+
const signer = (_a = options == null ? void 0 : options.experimental_signer) != null ? _a : this.signer.locator();
|
|
133
|
+
const transactionCreationResponse = yield this.apiClient.createTransaction(this.walletLocator, {
|
|
134
|
+
params: {
|
|
135
|
+
signer,
|
|
136
|
+
chain: this.chain,
|
|
137
|
+
calls: [transaction]
|
|
138
|
+
}
|
|
139
|
+
});
|
|
140
|
+
if ("error" in transactionCreationResponse) {
|
|
141
|
+
throw new (0, _chunkXC2V34TScjs.TransactionNotCreatedError)(JSON.stringify(transactionCreationResponse));
|
|
142
|
+
}
|
|
143
|
+
return transactionCreationResponse;
|
|
144
|
+
});
|
|
145
|
+
}
|
|
146
|
+
buildTransaction(params) {
|
|
147
|
+
var _a, _b, _c, _d, _e;
|
|
148
|
+
if ("transaction" in params) {
|
|
149
|
+
return { transaction: params.transaction };
|
|
150
|
+
}
|
|
151
|
+
if (params.abi == null) {
|
|
152
|
+
return {
|
|
153
|
+
to: params.to,
|
|
154
|
+
value: (_b = (_a = params.value) == null ? void 0 : _a.toString()) != null ? _b : "0",
|
|
155
|
+
data: (_c = params.data) != null ? _c : "0x"
|
|
156
|
+
};
|
|
157
|
+
}
|
|
158
|
+
if (!params.functionName) {
|
|
159
|
+
throw new Error("Function name is required");
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
to: params.to,
|
|
163
|
+
value: (_e = (_d = params.value) == null ? void 0 : _d.toString()) != null ? _e : "0",
|
|
164
|
+
data: _viem.encodeFunctionData.call(void 0, {
|
|
165
|
+
abi: params.abi,
|
|
166
|
+
functionName: params.functionName,
|
|
167
|
+
args: params.args
|
|
168
|
+
})
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
};
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
|
|
175
|
+
exports.EVMWallet = EVMWallet;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __typeError = (msg) => {
|
|
8
|
+
throw TypeError(msg);
|
|
9
|
+
};
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
24
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
25
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
26
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
27
|
+
var __async = (__this, __arguments, generator) => {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
var fulfilled = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.next(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var rejected = (value) => {
|
|
37
|
+
try {
|
|
38
|
+
step(generator.throw(value));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
reject(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
44
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export {
|
|
49
|
+
__spreadValues,
|
|
50
|
+
__spreadProps,
|
|
51
|
+
__privateGet,
|
|
52
|
+
__privateAdd,
|
|
53
|
+
__privateSet,
|
|
54
|
+
__async
|
|
55
|
+
};
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireWildcard(obj) { if (obj && obj.__esModule) { return obj; } else { var newObj = {}; if (obj != null) { for (var key in obj) { if (Object.prototype.hasOwnProperty.call(obj, key)) { newObj[key] = obj[key]; } } } newObj.default = obj; return newObj; } }
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkLHYSCUKJcjs = require('./chunk-LHYSCUKJ.cjs');
|
|
5
|
+
|
|
6
|
+
// src/logger/init.ts
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
var _commonsdkbase = require('@crossmint/common-sdk-base');
|
|
14
|
+
var _browserlogs = require('@datadog/browser-logs'); var datadogLogger = _interopRequireWildcard(_browserlogs);
|
|
15
|
+
var walletsLogger = new (0, _commonsdkbase.SdkLogger)();
|
|
16
|
+
function initWalletsLogger(apiKey) {
|
|
17
|
+
const platform = _commonsdkbase.detectPlatform.call(void 0, );
|
|
18
|
+
const validationResult = _commonsdkbase.validateAPIKey.call(void 0, apiKey);
|
|
19
|
+
if (!validationResult.isValid) {
|
|
20
|
+
throw new Error(`Invalid API key: ${validationResult.message}`);
|
|
21
|
+
}
|
|
22
|
+
const { environment, projectId } = validationResult;
|
|
23
|
+
walletsLogger.init({
|
|
24
|
+
packageName: _chunkLHYSCUKJcjs.SDK_NAME,
|
|
25
|
+
packageVersion: _chunkLHYSCUKJcjs.SDK_VERSION,
|
|
26
|
+
environment,
|
|
27
|
+
projectId,
|
|
28
|
+
platform
|
|
29
|
+
});
|
|
30
|
+
switch (platform) {
|
|
31
|
+
case "browser": {
|
|
32
|
+
const sink = new (0, _commonsdkbase.BrowserDatadogSink)(environment, datadogLogger);
|
|
33
|
+
walletsLogger.addSink(sink);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case "react-native": {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "server": {
|
|
40
|
+
const sink = new (0, _commonsdkbase.ServerDatadogSink)(environment);
|
|
41
|
+
walletsLogger.addSink(sink);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
default: {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
exports.walletsLogger = walletsLogger; exports.initWalletsLogger = initWalletsLogger;
|
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});var __defProp = Object.defineProperty;
|
|
2
|
+
var __defProps = Object.defineProperties;
|
|
3
|
+
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
|
|
4
|
+
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __propIsEnum = Object.prototype.propertyIsEnumerable;
|
|
7
|
+
var __typeError = (msg) => {
|
|
8
|
+
throw TypeError(msg);
|
|
9
|
+
};
|
|
10
|
+
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
|
|
11
|
+
var __spreadValues = (a, b) => {
|
|
12
|
+
for (var prop in b || (b = {}))
|
|
13
|
+
if (__hasOwnProp.call(b, prop))
|
|
14
|
+
__defNormalProp(a, prop, b[prop]);
|
|
15
|
+
if (__getOwnPropSymbols)
|
|
16
|
+
for (var prop of __getOwnPropSymbols(b)) {
|
|
17
|
+
if (__propIsEnum.call(b, prop))
|
|
18
|
+
__defNormalProp(a, prop, b[prop]);
|
|
19
|
+
}
|
|
20
|
+
return a;
|
|
21
|
+
};
|
|
22
|
+
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
|
|
23
|
+
var __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg);
|
|
24
|
+
var __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj));
|
|
25
|
+
var __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value);
|
|
26
|
+
var __privateSet = (obj, member, value, setter) => (__accessCheck(obj, member, "write to private field"), setter ? setter.call(obj, value) : member.set(obj, value), value);
|
|
27
|
+
var __async = (__this, __arguments, generator) => {
|
|
28
|
+
return new Promise((resolve, reject) => {
|
|
29
|
+
var fulfilled = (value) => {
|
|
30
|
+
try {
|
|
31
|
+
step(generator.next(value));
|
|
32
|
+
} catch (e) {
|
|
33
|
+
reject(e);
|
|
34
|
+
}
|
|
35
|
+
};
|
|
36
|
+
var rejected = (value) => {
|
|
37
|
+
try {
|
|
38
|
+
step(generator.throw(value));
|
|
39
|
+
} catch (e) {
|
|
40
|
+
reject(e);
|
|
41
|
+
}
|
|
42
|
+
};
|
|
43
|
+
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
|
|
44
|
+
step((generator = generator.apply(__this, __arguments)).next());
|
|
45
|
+
});
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
|
|
50
|
+
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
|
|
54
|
+
|
|
55
|
+
exports.__spreadValues = __spreadValues; exports.__spreadProps = __spreadProps; exports.__privateGet = __privateGet; exports.__privateAdd = __privateAdd; exports.__privateSet = __privateSet; exports.__async = __async;
|
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Wallet
|
|
3
|
+
} from "./chunk-UKBWSQ7R.js";
|
|
4
|
+
import {
|
|
5
|
+
SolanaExternalWalletSigner
|
|
6
|
+
} from "./chunk-DQCXGBZM.js";
|
|
7
|
+
import {
|
|
8
|
+
TransactionNotCreatedError
|
|
9
|
+
} from "./chunk-SGINWAB6.js";
|
|
10
|
+
import {
|
|
11
|
+
__async
|
|
12
|
+
} from "./chunk-FPMW7Q5O.js";
|
|
13
|
+
|
|
14
|
+
// src/wallets/solana.ts
|
|
15
|
+
import bs58 from "bs58";
|
|
16
|
+
import { isValidSolanaAddress } from "@crossmint/common-sdk-base";
|
|
17
|
+
var SolanaWallet = class _SolanaWallet extends Wallet {
|
|
18
|
+
constructor(wallet) {
|
|
19
|
+
super(
|
|
20
|
+
{
|
|
21
|
+
chain: wallet.chain,
|
|
22
|
+
address: wallet.address,
|
|
23
|
+
owner: wallet.owner,
|
|
24
|
+
signer: wallet.signer,
|
|
25
|
+
options: Wallet.getOptions(wallet),
|
|
26
|
+
alias: wallet.alias
|
|
27
|
+
},
|
|
28
|
+
Wallet.getApiClient(wallet)
|
|
29
|
+
);
|
|
30
|
+
}
|
|
31
|
+
static from(wallet) {
|
|
32
|
+
if (!isValidSolanaAddress(wallet.address)) {
|
|
33
|
+
throw new Error("Wallet is not a Solana wallet");
|
|
34
|
+
}
|
|
35
|
+
return new _SolanaWallet(wallet);
|
|
36
|
+
}
|
|
37
|
+
sendTransaction(params) {
|
|
38
|
+
return __async(this, null, function* () {
|
|
39
|
+
var _a, _b;
|
|
40
|
+
yield this.preAuthIfNeeded();
|
|
41
|
+
const createdTransaction = yield this.createTransaction(params);
|
|
42
|
+
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
43
|
+
return {
|
|
44
|
+
hash: void 0,
|
|
45
|
+
explorerLink: void 0,
|
|
46
|
+
transactionId: createdTransaction.id
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
const _additionalSigners = (_b = params.additionalSigners) == null ? void 0 : _b.map(
|
|
50
|
+
(signer) => new SolanaExternalWalletSigner({
|
|
51
|
+
type: "external-wallet",
|
|
52
|
+
address: signer.publicKey.toString(),
|
|
53
|
+
locator: `external-wallet:${signer.publicKey.toString()}`,
|
|
54
|
+
onSignTransaction: (transaction) => {
|
|
55
|
+
transaction.sign([signer]);
|
|
56
|
+
return Promise.resolve(transaction);
|
|
57
|
+
}
|
|
58
|
+
})
|
|
59
|
+
);
|
|
60
|
+
const options = {
|
|
61
|
+
additionalSigners: _additionalSigners
|
|
62
|
+
};
|
|
63
|
+
return yield this.approveTransactionAndWait(createdTransaction.id, options);
|
|
64
|
+
});
|
|
65
|
+
}
|
|
66
|
+
createTransaction(params) {
|
|
67
|
+
return __async(this, null, function* () {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
const signer = (_b = (_a = params.options) == null ? void 0 : _a.experimental_signer) != null ? _b : this.signer.locator();
|
|
70
|
+
let serializedTransaction;
|
|
71
|
+
if ("serializedTransaction" in params) {
|
|
72
|
+
serializedTransaction = params.serializedTransaction;
|
|
73
|
+
} else {
|
|
74
|
+
serializedTransaction = bs58.encode(params.transaction.serialize());
|
|
75
|
+
}
|
|
76
|
+
const transactionCreationResponse = yield this.apiClient.createTransaction(this.walletLocator, {
|
|
77
|
+
params: {
|
|
78
|
+
transaction: serializedTransaction,
|
|
79
|
+
signer
|
|
80
|
+
}
|
|
81
|
+
});
|
|
82
|
+
if ("error" in transactionCreationResponse) {
|
|
83
|
+
throw new TransactionNotCreatedError(JSON.stringify(transactionCreationResponse));
|
|
84
|
+
}
|
|
85
|
+
return transactionCreationResponse;
|
|
86
|
+
});
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
|
|
90
|
+
export {
|
|
91
|
+
SolanaWallet
|
|
92
|
+
};
|