@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,80 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
var _chunkB6JOIWRHcjs = require('./chunk-B6JOIWRH.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
|
|
8
|
+
|
|
9
|
+
// src/signers/non-custodial/ncs-evm-signer.ts
|
|
10
|
+
var _ox = require('ox');
|
|
11
|
+
var _viem = require('viem');
|
|
12
|
+
var EVMNonCustodialSigner = class _EVMNonCustodialSigner extends _chunkB6JOIWRHcjs.NonCustodialSigner {
|
|
13
|
+
constructor(config) {
|
|
14
|
+
super(config);
|
|
15
|
+
}
|
|
16
|
+
signMessage(message) {
|
|
17
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
18
|
+
const messageRaw = _viem.isHex.call(void 0, message) ? message : _viem.toHex.call(void 0, message);
|
|
19
|
+
const messageToSign = _ox.PersonalMessage.getSignPayload(messageRaw);
|
|
20
|
+
return yield this.sign(messageToSign);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
signTransaction(transaction) {
|
|
24
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
25
|
+
return yield this.sign(transaction);
|
|
26
|
+
});
|
|
27
|
+
}
|
|
28
|
+
sign(raw) {
|
|
29
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
30
|
+
var _a;
|
|
31
|
+
yield this.handleAuthRequired();
|
|
32
|
+
const jwt = this.getJwtOrThrow();
|
|
33
|
+
const hexString = raw.replace("0x", "");
|
|
34
|
+
const res = yield (_a = this.config.clientTEEConnection) == null ? void 0 : _a.sendAction({
|
|
35
|
+
event: "request:sign",
|
|
36
|
+
responseEvent: "response:sign",
|
|
37
|
+
data: {
|
|
38
|
+
authData: {
|
|
39
|
+
jwt,
|
|
40
|
+
apiKey: this.config.crossmint.apiKey
|
|
41
|
+
},
|
|
42
|
+
data: {
|
|
43
|
+
keyType: "secp256k1",
|
|
44
|
+
bytes: hexString,
|
|
45
|
+
encoding: "hex"
|
|
46
|
+
}
|
|
47
|
+
},
|
|
48
|
+
options: _chunkB6JOIWRHcjs.DEFAULT_EVENT_OPTIONS
|
|
49
|
+
});
|
|
50
|
+
if ((res == null ? void 0 : res.status) === "error") {
|
|
51
|
+
throw new Error(res.error);
|
|
52
|
+
}
|
|
53
|
+
if ((res == null ? void 0 : res.signature) == null) {
|
|
54
|
+
throw new Error("Failed to sign transaction");
|
|
55
|
+
}
|
|
56
|
+
_EVMNonCustodialSigner.verifyPublicKeyFormat(res.publicKey);
|
|
57
|
+
return { signature: res.signature.bytes };
|
|
58
|
+
});
|
|
59
|
+
}
|
|
60
|
+
static verifyPublicKeyFormat(publicKey) {
|
|
61
|
+
if (publicKey == null) {
|
|
62
|
+
throw new Error("No public key found");
|
|
63
|
+
}
|
|
64
|
+
if (publicKey.encoding !== "hex" || publicKey.keyType !== "secp256k1" || publicKey.bytes == null) {
|
|
65
|
+
throw new Error(
|
|
66
|
+
"Not supported. Expected public key to be in hex encoding and secp256k1 key type. Got: " + JSON.stringify(publicKey)
|
|
67
|
+
);
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
getChainKeyParams() {
|
|
71
|
+
return {
|
|
72
|
+
scheme: "secp256k1",
|
|
73
|
+
encoding: "hex"
|
|
74
|
+
};
|
|
75
|
+
}
|
|
76
|
+
};
|
|
77
|
+
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
exports.EVMNonCustodialSigner = EVMNonCustodialSigner;
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
|
|
4
|
+
|
|
5
|
+
// src/signers/solana-api-key.ts
|
|
6
|
+
var SolanaApiKeySigner = class {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.type = "api-key";
|
|
10
|
+
}
|
|
11
|
+
locator() {
|
|
12
|
+
return this.config.locator;
|
|
13
|
+
}
|
|
14
|
+
signMessage() {
|
|
15
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
16
|
+
return yield Promise.reject(
|
|
17
|
+
new Error(
|
|
18
|
+
"API key signers do not support direct message signing - signatures are handled automatically by the backend"
|
|
19
|
+
)
|
|
20
|
+
);
|
|
21
|
+
});
|
|
22
|
+
}
|
|
23
|
+
signTransaction() {
|
|
24
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
25
|
+
return yield Promise.reject(
|
|
26
|
+
new Error(
|
|
27
|
+
"API key signers do not support direct transaction signing - transaction are handled automatically by the backend"
|
|
28
|
+
)
|
|
29
|
+
);
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
};
|
|
33
|
+
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
exports.SolanaApiKeySigner = SolanaApiKeySigner;
|
|
@@ -0,0 +1,63 @@
|
|
|
1
|
+
import {
|
|
2
|
+
__async
|
|
3
|
+
} from "./chunk-FPMW7Q5O.js";
|
|
4
|
+
|
|
5
|
+
// src/signers/evm-external-wallet.ts
|
|
6
|
+
var EVMExternalWalletSigner = class {
|
|
7
|
+
constructor(config) {
|
|
8
|
+
this.config = config;
|
|
9
|
+
this.type = "external-wallet";
|
|
10
|
+
if (config.address == null) {
|
|
11
|
+
throw new Error("Please provide an address for the External Wallet Signer");
|
|
12
|
+
}
|
|
13
|
+
this._address = config.address;
|
|
14
|
+
this.provider = config.provider;
|
|
15
|
+
this.viemAccount = config.viemAccount;
|
|
16
|
+
}
|
|
17
|
+
address() {
|
|
18
|
+
return this._address;
|
|
19
|
+
}
|
|
20
|
+
locator() {
|
|
21
|
+
return this.config.locator;
|
|
22
|
+
}
|
|
23
|
+
signMessage(message) {
|
|
24
|
+
return __async(this, null, function* () {
|
|
25
|
+
var _a;
|
|
26
|
+
if (this.provider != null) {
|
|
27
|
+
const signature = yield this.provider.request({
|
|
28
|
+
method: "personal_sign",
|
|
29
|
+
params: [message, this._address]
|
|
30
|
+
});
|
|
31
|
+
if (signature == null) {
|
|
32
|
+
throw new Error(
|
|
33
|
+
"[EVMExternalWalletSigner] Failed to sign message: EIP1193 provider signMessage returned null"
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
return { signature };
|
|
37
|
+
}
|
|
38
|
+
if (((_a = this.viemAccount) == null ? void 0 : _a.signMessage) != null) {
|
|
39
|
+
const signature = yield this.viemAccount.signMessage({
|
|
40
|
+
message: {
|
|
41
|
+
raw: message
|
|
42
|
+
}
|
|
43
|
+
});
|
|
44
|
+
if (signature == null) {
|
|
45
|
+
throw new Error(
|
|
46
|
+
"[EVMExternalWalletSigner] Failed to sign message: Viem account signMessage returned null"
|
|
47
|
+
);
|
|
48
|
+
}
|
|
49
|
+
return { signature };
|
|
50
|
+
}
|
|
51
|
+
throw new Error("No signer provider or viem account provided");
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
signTransaction(transaction) {
|
|
55
|
+
return __async(this, null, function* () {
|
|
56
|
+
return yield this.signMessage(transaction);
|
|
57
|
+
});
|
|
58
|
+
}
|
|
59
|
+
};
|
|
60
|
+
|
|
61
|
+
export {
|
|
62
|
+
EVMExternalWalletSigner
|
|
63
|
+
};
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/chains/definitions/story.ts
|
|
2
|
+
var _viem = require('viem');
|
|
3
|
+
var story = _viem.defineChain.call(void 0, {
|
|
4
|
+
id: 1514,
|
|
5
|
+
name: "Story",
|
|
6
|
+
nativeCurrency: {
|
|
7
|
+
decimals: 18,
|
|
8
|
+
name: "IP Token",
|
|
9
|
+
symbol: "IP"
|
|
10
|
+
},
|
|
11
|
+
rpcUrls: {
|
|
12
|
+
default: { http: ["https://mainnet.storyrpc.io"] }
|
|
13
|
+
},
|
|
14
|
+
testnet: false
|
|
15
|
+
});
|
|
16
|
+
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
exports.story = story;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Wallet
|
|
3
|
+
} from "./chunk-UKBWSQ7R.js";
|
|
4
|
+
import {
|
|
5
|
+
TransactionNotCreatedError
|
|
6
|
+
} from "./chunk-SGINWAB6.js";
|
|
7
|
+
import {
|
|
8
|
+
__async
|
|
9
|
+
} from "./chunk-FPMW7Q5O.js";
|
|
10
|
+
|
|
11
|
+
// src/wallets/stellar.ts
|
|
12
|
+
import { isValidStellarAddress } from "@crossmint/common-sdk-base";
|
|
13
|
+
var StellarWallet = class _StellarWallet extends Wallet {
|
|
14
|
+
constructor(wallet) {
|
|
15
|
+
super(
|
|
16
|
+
{
|
|
17
|
+
chain: wallet.chain,
|
|
18
|
+
address: wallet.address,
|
|
19
|
+
owner: wallet.owner,
|
|
20
|
+
signer: wallet.signer,
|
|
21
|
+
options: Wallet.getOptions(wallet),
|
|
22
|
+
alias: wallet.alias
|
|
23
|
+
},
|
|
24
|
+
Wallet.getApiClient(wallet)
|
|
25
|
+
);
|
|
26
|
+
}
|
|
27
|
+
static from(wallet) {
|
|
28
|
+
if (!isValidStellarAddress(wallet.address)) {
|
|
29
|
+
throw new Error("Wallet is not a Stellar wallet");
|
|
30
|
+
}
|
|
31
|
+
return new _StellarWallet(wallet);
|
|
32
|
+
}
|
|
33
|
+
sendTransaction(params) {
|
|
34
|
+
return __async(this, null, function* () {
|
|
35
|
+
var _a;
|
|
36
|
+
yield this.preAuthIfNeeded();
|
|
37
|
+
const createdTransaction = yield this.createTransaction(params);
|
|
38
|
+
if ((_a = params.options) == null ? void 0 : _a.experimental_prepareOnly) {
|
|
39
|
+
return {
|
|
40
|
+
hash: void 0,
|
|
41
|
+
explorerLink: void 0,
|
|
42
|
+
transactionId: createdTransaction.id
|
|
43
|
+
};
|
|
44
|
+
}
|
|
45
|
+
const options = {};
|
|
46
|
+
return yield this.approveTransactionAndWait(createdTransaction.id, options);
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
createTransaction(params) {
|
|
50
|
+
return __async(this, null, function* () {
|
|
51
|
+
var _a;
|
|
52
|
+
const { contractId, options } = params;
|
|
53
|
+
const signer = (_a = options == null ? void 0 : options.experimental_signer) != null ? _a : this.signer.locator();
|
|
54
|
+
let transaction;
|
|
55
|
+
if ("transaction" in params) {
|
|
56
|
+
transaction = {
|
|
57
|
+
type: "serialized-transaction",
|
|
58
|
+
serializedTransaction: params.transaction,
|
|
59
|
+
contractId
|
|
60
|
+
};
|
|
61
|
+
} else {
|
|
62
|
+
const { method, memo, args } = params;
|
|
63
|
+
transaction = {
|
|
64
|
+
type: "contract-call",
|
|
65
|
+
contractId,
|
|
66
|
+
method,
|
|
67
|
+
memo: memo != null ? { type: "text", value: memo } : void 0,
|
|
68
|
+
args
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
const transactionCreationResponse = yield this.apiClient.createTransaction(this.walletLocator, {
|
|
72
|
+
params: {
|
|
73
|
+
transaction,
|
|
74
|
+
signer
|
|
75
|
+
}
|
|
76
|
+
});
|
|
77
|
+
if ("error" in transactionCreationResponse) {
|
|
78
|
+
throw new TransactionNotCreatedError(JSON.stringify(transactionCreationResponse));
|
|
79
|
+
}
|
|
80
|
+
return transactionCreationResponse;
|
|
81
|
+
});
|
|
82
|
+
}
|
|
83
|
+
};
|
|
84
|
+
|
|
85
|
+
export {
|
|
86
|
+
StellarWallet
|
|
87
|
+
};
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }
|
|
2
|
+
|
|
3
|
+
var _chunkXC2V34TScjs = require('./chunk-XC2V34TS.cjs');
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _chunkG5NYLGM5cjs = require('./chunk-G5NYLGM5.cjs');
|
|
7
|
+
|
|
8
|
+
// src/signers/solana-external-wallet.ts
|
|
9
|
+
var _web3js = require('@solana/web3.js');
|
|
10
|
+
var _bs58 = require('bs58'); var _bs582 = _interopRequireDefault(_bs58);
|
|
11
|
+
var SolanaExternalWalletSigner = class {
|
|
12
|
+
constructor(config) {
|
|
13
|
+
this.config = config;
|
|
14
|
+
this.type = "external-wallet";
|
|
15
|
+
if (config.address == null) {
|
|
16
|
+
throw new Error("Please provide an address for the External Wallet Signer");
|
|
17
|
+
}
|
|
18
|
+
this._address = config.address;
|
|
19
|
+
this.onSignTransaction = config.onSignTransaction;
|
|
20
|
+
}
|
|
21
|
+
address() {
|
|
22
|
+
return this._address;
|
|
23
|
+
}
|
|
24
|
+
locator() {
|
|
25
|
+
return this.config.locator;
|
|
26
|
+
}
|
|
27
|
+
signMessage() {
|
|
28
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
29
|
+
return yield Promise.reject(new Error("signMessage method not implemented for solana external wallet signer"));
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
signTransaction(transaction) {
|
|
33
|
+
return _chunkG5NYLGM5cjs.__async.call(void 0, this, null, function* () {
|
|
34
|
+
if (this.onSignTransaction == null) {
|
|
35
|
+
return yield Promise.reject(
|
|
36
|
+
new Error("onSignTransaction method is required to sign transactions with a Solana external wallet")
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
const transactionBytes = _bs582.default.decode(transaction);
|
|
40
|
+
const deserializedTransaction = _web3js.VersionedTransaction.deserialize(transactionBytes);
|
|
41
|
+
const signedTxn = yield this.onSignTransaction(deserializedTransaction);
|
|
42
|
+
const externalWalletPublicKey = new (0, _web3js.PublicKey)(this._address);
|
|
43
|
+
const signerIndex = signedTxn.message.staticAccountKeys.findIndex((key) => key.equals(externalWalletPublicKey));
|
|
44
|
+
if (signerIndex === -1) {
|
|
45
|
+
throw new (0, _chunkXC2V34TScjs.TransactionFailedError)("Wallet public key not found in transaction signers");
|
|
46
|
+
}
|
|
47
|
+
const validSignature = signedTxn.signatures[signerIndex];
|
|
48
|
+
if (validSignature == null) {
|
|
49
|
+
throw new (0, _chunkXC2V34TScjs.TransactionFailedError)("No valid signature found in the transaction");
|
|
50
|
+
}
|
|
51
|
+
const signatureBytes = new Uint8Array(Object.values(validSignature));
|
|
52
|
+
return { signature: _bs582.default.encode(signatureBytes) };
|
|
53
|
+
});
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
|
|
59
|
+
exports.SolanaExternalWalletSigner = SolanaExternalWalletSigner;
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import {
|
|
2
|
+
SDK_NAME,
|
|
3
|
+
SDK_VERSION
|
|
4
|
+
} from "./chunk-WQVJM3PG.js";
|
|
5
|
+
|
|
6
|
+
// src/logger/init.ts
|
|
7
|
+
import {
|
|
8
|
+
SdkLogger,
|
|
9
|
+
BrowserDatadogSink,
|
|
10
|
+
detectPlatform,
|
|
11
|
+
validateAPIKey,
|
|
12
|
+
ServerDatadogSink
|
|
13
|
+
} from "@crossmint/common-sdk-base";
|
|
14
|
+
import * as datadogLogger from "@datadog/browser-logs";
|
|
15
|
+
var walletsLogger = new SdkLogger();
|
|
16
|
+
function initWalletsLogger(apiKey) {
|
|
17
|
+
const platform = detectPlatform();
|
|
18
|
+
const validationResult = validateAPIKey(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: SDK_NAME,
|
|
25
|
+
packageVersion: SDK_VERSION,
|
|
26
|
+
environment,
|
|
27
|
+
projectId,
|
|
28
|
+
platform
|
|
29
|
+
});
|
|
30
|
+
switch (platform) {
|
|
31
|
+
case "browser": {
|
|
32
|
+
const sink = new BrowserDatadogSink(environment, datadogLogger);
|
|
33
|
+
walletsLogger.addSink(sink);
|
|
34
|
+
break;
|
|
35
|
+
}
|
|
36
|
+
case "react-native": {
|
|
37
|
+
break;
|
|
38
|
+
}
|
|
39
|
+
case "server": {
|
|
40
|
+
const sink = new ServerDatadogSink(environment);
|
|
41
|
+
walletsLogger.addSink(sink);
|
|
42
|
+
break;
|
|
43
|
+
}
|
|
44
|
+
default: {
|
|
45
|
+
break;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export {
|
|
51
|
+
walletsLogger,
|
|
52
|
+
initWalletsLogger
|
|
53
|
+
};
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});
|
|
2
|
+
|
|
3
|
+
var _chunkXC2V34TScjs = require('./chunk-XC2V34TS.cjs');
|
|
4
|
+
|
|
5
|
+
// src/utils/signer-validation.ts
|
|
6
|
+
var _commonsdkauth = require('@crossmint/common-sdk-auth');
|
|
7
|
+
var signerConfigMismatchErrorMessage = (fieldPath, newValue, existingValue) => `Wallet signer configuration mismatch at "${fieldPath}" - expected "${existingValue}" from existing wallet but found "${newValue}"`;
|
|
8
|
+
function normalizeEmail(email) {
|
|
9
|
+
const lowerCaseEmail = email.toLowerCase();
|
|
10
|
+
const emailParts = lowerCaseEmail.split("@");
|
|
11
|
+
const domain = emailParts[1];
|
|
12
|
+
const isGoogleMailDomain = domain === "googlemail.com";
|
|
13
|
+
const isGmail = isGoogleMailDomain || domain === "gmail.com";
|
|
14
|
+
const isGmailAndHasDots = isGmail && emailParts[0].includes(".");
|
|
15
|
+
if (isGoogleMailDomain) {
|
|
16
|
+
emailParts[1] = "gmail.com";
|
|
17
|
+
}
|
|
18
|
+
if (isGmailAndHasDots) {
|
|
19
|
+
emailParts[0] = emailParts[0].replace(/\./g, "");
|
|
20
|
+
}
|
|
21
|
+
return `${emailParts[0]}@${emailParts[1]}`;
|
|
22
|
+
}
|
|
23
|
+
function normalizeValueForComparison(value) {
|
|
24
|
+
if (typeof value === "string" && _commonsdkauth.isEmailValid.call(void 0, value)) {
|
|
25
|
+
return normalizeEmail(value);
|
|
26
|
+
}
|
|
27
|
+
return value;
|
|
28
|
+
}
|
|
29
|
+
function compareSignerConfigs(newSignerConfig, existingSignerConfig, path = "") {
|
|
30
|
+
if (newSignerConfig === existingSignerConfig) {
|
|
31
|
+
return;
|
|
32
|
+
}
|
|
33
|
+
if (newSignerConfig == null || existingSignerConfig == null) {
|
|
34
|
+
throw new Error(`Cannot compare null or undefined signer configs at path: ${path}`);
|
|
35
|
+
}
|
|
36
|
+
for (const key of Object.keys(newSignerConfig)) {
|
|
37
|
+
if (!(key in existingSignerConfig)) {
|
|
38
|
+
continue;
|
|
39
|
+
}
|
|
40
|
+
const fieldPath = path ? `${path}.${key}` : key;
|
|
41
|
+
const newValue = newSignerConfig[key];
|
|
42
|
+
const existingValue = existingSignerConfig[key];
|
|
43
|
+
if (typeof newValue === "object" && newValue !== null && typeof existingValue === "object" && existingValue !== null) {
|
|
44
|
+
compareSignerConfigs(
|
|
45
|
+
newValue,
|
|
46
|
+
existingValue,
|
|
47
|
+
fieldPath
|
|
48
|
+
);
|
|
49
|
+
} else if (normalizeValueForComparison(newValue) !== normalizeValueForComparison(existingValue)) {
|
|
50
|
+
throw new (0, _chunkXC2V34TScjs.WalletCreationError)(signerConfigMismatchErrorMessage(fieldPath, newValue, existingValue));
|
|
51
|
+
}
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
exports.normalizeValueForComparison = normalizeValueForComparison; exports.compareSignerConfigs = compareSignerConfigs;
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/signers/types.ts
|
|
2
|
+
var AuthRejectedError = class extends Error {
|
|
3
|
+
constructor() {
|
|
4
|
+
super("Authentication was rejected by the user");
|
|
5
|
+
this.name = "AuthRejectedError";
|
|
6
|
+
}
|
|
7
|
+
};
|
|
8
|
+
function isExportableSigner(signer) {
|
|
9
|
+
return signer._exportPrivateKey !== void 0;
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
exports.AuthRejectedError = AuthRejectedError; exports.isExportableSigner = isExportableSigner;
|