@txnlab/use-wallet 0.1.19 → 0.1.21
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/cjs/algod/index.d.ts +9 -3
- package/dist/cjs/base-9794b627.js +174 -0
- package/dist/cjs/base-9794b627.js.map +1 -0
- package/dist/cjs/clients/algosigner.d.ts +4 -1
- package/dist/cjs/clients/algosigner.js +144 -0
- package/dist/cjs/clients/algosigner.js.map +1 -0
- package/dist/cjs/clients/base.d.ts +6 -4
- package/dist/cjs/clients/defly.d.ts +9 -2
- package/dist/cjs/clients/defly.js +159 -0
- package/dist/cjs/clients/defly.js.map +1 -0
- package/dist/cjs/clients/exodus.d.ts +4 -1
- package/dist/cjs/clients/exodus.js +118 -0
- package/dist/cjs/clients/exodus.js.map +1 -0
- package/dist/cjs/clients/index.d.ts +7 -7
- package/dist/cjs/clients/kmd.d.ts +5 -3
- package/dist/cjs/clients/kmd.js +140 -0
- package/dist/cjs/clients/kmd.js.map +1 -0
- package/dist/cjs/clients/myalgowallet.d.ts +5 -2
- package/dist/cjs/clients/myalgowallet.js +128 -0
- package/dist/cjs/clients/myalgowallet.js.map +1 -0
- package/dist/cjs/clients/perawallet.d.ts +5 -2
- package/dist/cjs/clients/perawallet.js +169 -0
- package/dist/cjs/clients/perawallet.js.map +1 -0
- package/dist/cjs/clients/walletconnect.d.ts +9 -2
- package/dist/cjs/clients/walletconnect.js +199 -0
- package/dist/cjs/clients/walletconnect.js.map +1 -0
- package/dist/cjs/constants-e76d1f05.js +63 -0
- package/dist/cjs/constants-e76d1f05.js.map +1 -0
- package/dist/cjs/constants.js +22 -0
- package/dist/cjs/constants.js.map +1 -0
- package/dist/cjs/hooks/useWallet.d.ts +1 -1
- package/dist/cjs/index.d.ts +1 -5
- package/dist/cjs/index.js +43 -1241
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/providers/index.d.ts +7 -7
- package/dist/cjs/providers.js +81 -0
- package/dist/cjs/providers.js.map +1 -0
- package/dist/cjs/types/api.d.ts +1 -1
- package/dist/cjs/types/node.d.ts +2 -3
- package/dist/cjs/utils.js +74 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/esm/algod/index.d.ts +9 -3
- package/dist/esm/base-71089716.js +152 -0
- package/dist/esm/base-71089716.js.map +1 -0
- package/dist/esm/clients/algosigner.d.ts +4 -1
- package/dist/esm/clients/algosigner.js +142 -0
- package/dist/esm/clients/algosigner.js.map +1 -0
- package/dist/esm/clients/base.d.ts +6 -4
- package/dist/esm/clients/defly.d.ts +9 -2
- package/dist/esm/clients/defly.js +139 -0
- package/dist/esm/clients/defly.js.map +1 -0
- package/dist/esm/clients/exodus.d.ts +4 -1
- package/dist/esm/clients/exodus.js +116 -0
- package/dist/esm/clients/exodus.js.map +1 -0
- package/dist/esm/clients/index.d.ts +7 -7
- package/dist/esm/clients/kmd.d.ts +5 -3
- package/dist/esm/clients/kmd.js +138 -0
- package/dist/esm/clients/kmd.js.map +1 -0
- package/dist/esm/clients/myalgowallet.d.ts +5 -2
- package/dist/esm/clients/myalgowallet.js +108 -0
- package/dist/esm/clients/myalgowallet.js.map +1 -0
- package/dist/esm/clients/perawallet.d.ts +5 -2
- package/dist/esm/clients/perawallet.js +149 -0
- package/dist/esm/clients/perawallet.js.map +1 -0
- package/dist/esm/clients/walletconnect.d.ts +9 -2
- package/dist/esm/clients/walletconnect.js +179 -0
- package/dist/esm/clients/walletconnect.js.map +1 -0
- package/dist/esm/constants-49b44514.js +53 -0
- package/dist/esm/constants-49b44514.js.map +1 -0
- package/dist/esm/constants.js +2 -0
- package/dist/esm/constants.js.map +1 -0
- package/dist/esm/hooks/useWallet.d.ts +1 -1
- package/dist/esm/index.d.ts +1 -5
- package/dist/esm/index.js +18 -1209
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/providers/index.d.ts +7 -7
- package/dist/esm/providers.js +77 -0
- package/dist/esm/providers.js.map +1 -0
- package/dist/esm/types/api.d.ts +1 -1
- package/dist/esm/types/node.d.ts +2 -3
- package/dist/esm/utils.js +70 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/index.d.ts +23 -419
- package/package.json +1 -1
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('../base-9794b627.js');
|
|
4
|
+
var constants = require('../constants-e76d1f05.js');
|
|
5
|
+
var providers = require('../providers.js');
|
|
6
|
+
|
|
7
|
+
class AlgoSignerClient extends base.BaseWallet {
|
|
8
|
+
#client;
|
|
9
|
+
id;
|
|
10
|
+
provider;
|
|
11
|
+
constructor({ client, id, provider, algosdk, algodClient }) {
|
|
12
|
+
super(algosdk, algodClient);
|
|
13
|
+
this.#client = client;
|
|
14
|
+
this.id = id;
|
|
15
|
+
this.provider = provider;
|
|
16
|
+
}
|
|
17
|
+
static async init() {
|
|
18
|
+
if (typeof window == "undefined" ||
|
|
19
|
+
window.AlgoSigner === undefined) {
|
|
20
|
+
throw new Error("AlgoSigner is not available.");
|
|
21
|
+
}
|
|
22
|
+
const { algosdk, algodClient } = await base.Algod.init();
|
|
23
|
+
const algoSigner = window.AlgoSigner;
|
|
24
|
+
return new AlgoSignerClient({
|
|
25
|
+
id: constants.PROVIDER_ID.ALGO_SIGNER,
|
|
26
|
+
client: algoSigner,
|
|
27
|
+
provider: providers.providers[constants.PROVIDER_ID.ALGO_SIGNER],
|
|
28
|
+
algosdk: algosdk,
|
|
29
|
+
algodClient: algodClient,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async connect() {
|
|
33
|
+
await this.#client.connect();
|
|
34
|
+
let ledger = "MainNet";
|
|
35
|
+
if (constants.NODE_NETWORK === "mainnet") {
|
|
36
|
+
ledger = "MainNet";
|
|
37
|
+
}
|
|
38
|
+
else if (constants.NODE_NETWORK === "betanet") {
|
|
39
|
+
ledger = "BetaNet";
|
|
40
|
+
}
|
|
41
|
+
else if (constants.NODE_NETWORK === "testnet") {
|
|
42
|
+
ledger = "TestNet";
|
|
43
|
+
}
|
|
44
|
+
else if (!!constants.NODE_NETWORK) {
|
|
45
|
+
ledger = constants.NODE_NETWORK;
|
|
46
|
+
}
|
|
47
|
+
const accounts = await this.#client.accounts({
|
|
48
|
+
ledger,
|
|
49
|
+
});
|
|
50
|
+
if (accounts.length === 0) {
|
|
51
|
+
throw new Error(`No accounts found for ${this.provider}`);
|
|
52
|
+
}
|
|
53
|
+
const mappedAccounts = accounts.map(({ address }, index) => ({
|
|
54
|
+
name: `AlgoSigner ${index + 1}`,
|
|
55
|
+
address,
|
|
56
|
+
providerId: this.provider.id,
|
|
57
|
+
}));
|
|
58
|
+
return {
|
|
59
|
+
...this.provider,
|
|
60
|
+
accounts: mappedAccounts,
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
async reconnect(onDisconnect) {
|
|
64
|
+
if (window === undefined ||
|
|
65
|
+
window.AlgoSigner === undefined) {
|
|
66
|
+
onDisconnect();
|
|
67
|
+
}
|
|
68
|
+
return null;
|
|
69
|
+
}
|
|
70
|
+
async disconnect() {
|
|
71
|
+
return;
|
|
72
|
+
}
|
|
73
|
+
formatTransactionsArray(transactions) {
|
|
74
|
+
const formattedTransactions = transactions.map(([type, txn]) => {
|
|
75
|
+
const formattedTxn = {
|
|
76
|
+
txn: txn[1],
|
|
77
|
+
};
|
|
78
|
+
if (type === "s") {
|
|
79
|
+
formattedTxn.signers = [];
|
|
80
|
+
const decoded = this.algosdk.decodeSignedTransaction(new Uint8Array(Buffer.from(txn, "base64")));
|
|
81
|
+
formattedTxn.txn = this.#client.encoding.msgpackToBase64(decoded.txn.toByte());
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
const decoded = this.algosdk.decodeUnsignedTransaction(Buffer.from(txn, "base64"));
|
|
85
|
+
formattedTxn.txn = this.#client.encoding.msgpackToBase64(decoded.toByte());
|
|
86
|
+
}
|
|
87
|
+
return formattedTxn;
|
|
88
|
+
});
|
|
89
|
+
return formattedTransactions;
|
|
90
|
+
}
|
|
91
|
+
async signTransactions(activeAdress, transactions) {
|
|
92
|
+
// Decode the transactions to access their properties.
|
|
93
|
+
const decodedTxns = transactions.map((txn) => {
|
|
94
|
+
return this.algosdk.decodeObj(txn);
|
|
95
|
+
});
|
|
96
|
+
// Marshal the transactions,
|
|
97
|
+
// and add the signers property if they shouldn't be signed.
|
|
98
|
+
const txnsToSign = decodedTxns.reduce((acc, txn, i) => {
|
|
99
|
+
const txnObj = {
|
|
100
|
+
txn: this.#client.encoding.msgpackToBase64(transactions[i]),
|
|
101
|
+
};
|
|
102
|
+
if ("txn" in txn ||
|
|
103
|
+
this.algosdk.encodeAddress(txn["snd"]) !== activeAdress) {
|
|
104
|
+
txnObj.txn = this.#client.encoding.msgpackToBase64(this.algosdk.decodeSignedTransaction(transactions[i]).txn.toByte());
|
|
105
|
+
txnObj.signers = [];
|
|
106
|
+
}
|
|
107
|
+
acc.push(txnObj);
|
|
108
|
+
return acc;
|
|
109
|
+
}, []);
|
|
110
|
+
// Sign them with the client.
|
|
111
|
+
const result = await this.#client.signTxn(txnsToSign);
|
|
112
|
+
// Join the newly signed transactions with the original group of transactions.
|
|
113
|
+
const signedTxns = result.reduce((acc, txn, i) => {
|
|
114
|
+
if (txn) {
|
|
115
|
+
acc.push(new Uint8Array(Buffer.from(txn.blob, "base64")));
|
|
116
|
+
}
|
|
117
|
+
else {
|
|
118
|
+
acc.push(transactions[i]);
|
|
119
|
+
}
|
|
120
|
+
return acc;
|
|
121
|
+
}, []);
|
|
122
|
+
return signedTxns;
|
|
123
|
+
}
|
|
124
|
+
async signEncodedTransactions(transactions) {
|
|
125
|
+
const transactionsToSign = this.formatTransactionsArray(transactions);
|
|
126
|
+
const result = await this.#client.signTxn(transactionsToSign);
|
|
127
|
+
if (!result) {
|
|
128
|
+
throw new Error("Signing failed.");
|
|
129
|
+
}
|
|
130
|
+
const signedRawTransactions = result.reduce((signedTxns, txn, currentIndex) => {
|
|
131
|
+
if (txn) {
|
|
132
|
+
signedTxns.push(new Uint8Array(Buffer.from(txn.blob, "base64")));
|
|
133
|
+
}
|
|
134
|
+
if (txn === null) {
|
|
135
|
+
signedTxns.push(new Uint8Array(Buffer.from(transactions[currentIndex][1], "base64")));
|
|
136
|
+
}
|
|
137
|
+
return signedTxns;
|
|
138
|
+
}, []);
|
|
139
|
+
return signedRawTransactions;
|
|
140
|
+
}
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
module.exports = AlgoSignerClient;
|
|
144
|
+
//# sourceMappingURL=algosigner.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"algosigner.js","sources":["../../../src/clients/algosigner.ts"],"sourcesContent":["/**\n * Helpful resources:\n * https://github.com/PureStake/algosigner/blob/develop/docs/dApp-integration.md\n */\nimport type _algosdk from \"algosdk\";\nimport BaseWallet from \"./base\";\nimport Algod from \"../algod\";\nimport { PROVIDER_ID, NODE_NETWORK } from \"../constants\";\nimport { providers } from \"../providers\";\nimport type { WalletProvider } from \"../types\";\nimport { TransactionsArray } from \"../types\";\nimport type { DecodedTransaction, DecodedSignedTransaction } from \"../types\";\n\ntype WindowExtended = { AlgoSigner: AlgoSigner } & Window & typeof globalThis;\n\ntype AlgoSignerTransaction = {\n txn: string;\n // array of addresses to sign with (defaults to the sender),\n // setting this to an empty array tells AlgoSigner\n // that this transaction is not meant to be signed\n signers?: [];\n multisig?: string; // address of a multisig wallet to sign with\n};\n\ntype SupportedLedgers = \"MainNet\" | \"TestNet\" | \"BetaNet\" | string;\n\ntype AlgoSigner = {\n connect: () => Promise<Record<string, never>>;\n accounts: (ledger: {\n ledger: SupportedLedgers;\n }) => Promise<{ address: string }[]>;\n signTxn: (transactions: AlgoSignerTransaction[]) => Promise<\n {\n txID: string;\n blob: string;\n }[]\n >;\n encoding: {\n msgpackToBase64(transaction: Uint8Array): string;\n byteArrayToString(transaction: Uint8Array): string;\n };\n};\n\ntype InitWallet = {\n client: AlgoSigner;\n id: PROVIDER_ID;\n provider: WalletProvider;\n algosdk: typeof _algosdk;\n algodClient: _algosdk.Algodv2;\n};\n\nclass AlgoSignerClient extends BaseWallet {\n #client: AlgoSigner;\n id: PROVIDER_ID;\n provider: WalletProvider;\n\n constructor({ client, id, provider, algosdk, algodClient }: InitWallet) {\n super(algosdk, algodClient);\n\n this.#client = client;\n this.id = id;\n this.provider = provider;\n }\n\n static async init() {\n if (\n typeof window == \"undefined\" ||\n (window as WindowExtended).AlgoSigner === undefined\n ) {\n throw new Error(\"AlgoSigner is not available.\");\n }\n\n const { algosdk, algodClient } = await Algod.init();\n const algoSigner = (window as WindowExtended).AlgoSigner as AlgoSigner;\n\n return new AlgoSignerClient({\n id: PROVIDER_ID.ALGO_SIGNER,\n client: algoSigner,\n provider: providers[PROVIDER_ID.ALGO_SIGNER],\n algosdk: algosdk,\n algodClient: algodClient,\n });\n }\n\n async connect() {\n await this.#client.connect();\n\n let ledger: SupportedLedgers = \"MainNet\";\n\n if (NODE_NETWORK === \"mainnet\") {\n ledger = \"MainNet\";\n } else if (NODE_NETWORK === \"betanet\") {\n ledger = \"BetaNet\";\n } else if (NODE_NETWORK === \"testnet\") {\n ledger = \"TestNet\";\n } else if (!!NODE_NETWORK) {\n ledger = NODE_NETWORK;\n }\n\n const accounts = await this.#client.accounts({\n ledger,\n });\n\n if (accounts.length === 0) {\n throw new Error(`No accounts found for ${this.provider}`);\n }\n\n const mappedAccounts = accounts.map(({ address }, index) => ({\n name: `AlgoSigner ${index + 1}`,\n address,\n providerId: this.provider.id,\n }));\n\n return {\n ...this.provider,\n accounts: mappedAccounts,\n };\n }\n\n async reconnect(onDisconnect: () => void) {\n if (\n window === undefined ||\n (window as WindowExtended).AlgoSigner === undefined\n ) {\n onDisconnect();\n }\n\n return null;\n }\n\n async disconnect() {\n return;\n }\n\n formatTransactionsArray(\n transactions: TransactionsArray\n ): AlgoSignerTransaction[] {\n const formattedTransactions = transactions.map(([type, txn]) => {\n const formattedTxn: AlgoSignerTransaction = {\n txn: txn[1],\n };\n\n if (type === \"s\") {\n formattedTxn.signers = [];\n const decoded = this.algosdk.decodeSignedTransaction(\n new Uint8Array(Buffer.from(txn, \"base64\"))\n );\n formattedTxn.txn = this.#client.encoding.msgpackToBase64(\n decoded.txn.toByte()\n );\n } else {\n const decoded = this.algosdk.decodeUnsignedTransaction(\n Buffer.from(txn, \"base64\")\n );\n formattedTxn.txn = this.#client.encoding.msgpackToBase64(\n decoded.toByte()\n );\n }\n\n return formattedTxn;\n });\n\n return formattedTransactions;\n }\n\n async signTransactions(activeAdress: string, transactions: Uint8Array[]) {\n // Decode the transactions to access their properties.\n const decodedTxns = transactions.map((txn) => {\n return this.algosdk.decodeObj(txn);\n }) as Array<DecodedTransaction | DecodedSignedTransaction>;\n\n // Marshal the transactions,\n // and add the signers property if they shouldn't be signed.\n const txnsToSign = decodedTxns.reduce<AlgoSignerTransaction[]>(\n (acc, txn, i) => {\n const txnObj: AlgoSignerTransaction = {\n txn: this.#client.encoding.msgpackToBase64(transactions[i]),\n };\n\n if (\n \"txn\" in txn ||\n this.algosdk.encodeAddress(txn[\"snd\"]) !== activeAdress\n ) {\n txnObj.txn = this.#client.encoding.msgpackToBase64(\n this.algosdk.decodeSignedTransaction(transactions[i]).txn.toByte()\n );\n txnObj.signers = [];\n }\n\n acc.push(txnObj);\n\n return acc;\n },\n []\n );\n\n // Sign them with the client.\n const result = await this.#client.signTxn(txnsToSign);\n\n // Join the newly signed transactions with the original group of transactions.\n const signedTxns = result.reduce<Uint8Array[]>((acc, txn, i) => {\n if (txn) {\n acc.push(new Uint8Array(Buffer.from(txn.blob, \"base64\")));\n } else {\n acc.push(transactions[i]);\n }\n\n return acc;\n }, []);\n\n return signedTxns;\n }\n\n async signEncodedTransactions(transactions: TransactionsArray) {\n const transactionsToSign = this.formatTransactionsArray(transactions);\n const result = await this.#client.signTxn(transactionsToSign);\n\n if (!result) {\n throw new Error(\"Signing failed.\");\n }\n\n const signedRawTransactions = result.reduce(\n (signedTxns: Uint8Array[], txn, currentIndex) => {\n if (txn) {\n signedTxns.push(new Uint8Array(Buffer.from(txn.blob, \"base64\")));\n }\n\n if (txn === null) {\n signedTxns.push(\n new Uint8Array(Buffer.from(transactions[currentIndex][1], \"base64\"))\n );\n }\n\n return signedTxns;\n },\n []\n );\n\n return signedRawTransactions;\n }\n}\n\nexport default AlgoSignerClient;\n"],"names":["BaseWallet","Algod","PROVIDER_ID","providers","NODE_NETWORK"],"mappings":";;;;;;AAmDA,MAAM,gBAAiB,SAAQA,eAAU,CAAA;AACvC,IAAA,OAAO,CAAa;AACpB,IAAA,EAAE,CAAc;AAChB,IAAA,QAAQ,CAAiB;IAEzB,WAAY,CAAA,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAc,EAAA;AACpE,QAAA,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE5B,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;AACtB,QAAA,IAAI,CAAC,EAAE,GAAG,EAAE,CAAC;AACb,QAAA,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;KAC1B;IAED,aAAa,IAAI,GAAA;QACf,IACE,OAAO,MAAM,IAAI,WAAW;AAC3B,YAAA,MAAyB,CAAC,UAAU,KAAK,SAAS,EACnD;AACA,YAAA,MAAM,IAAI,KAAK,CAAC,8BAA8B,CAAC,CAAC;AACjD,SAAA;QAED,MAAM,EAAE,OAAO,EAAE,WAAW,EAAE,GAAG,MAAMC,UAAK,CAAC,IAAI,EAAE,CAAC;AACpD,QAAA,MAAM,UAAU,GAAI,MAAyB,CAAC,UAAwB,CAAC;QAEvE,OAAO,IAAI,gBAAgB,CAAC;YAC1B,EAAE,EAAEC,qBAAW,CAAC,WAAW;AAC3B,YAAA,MAAM,EAAE,UAAU;AAClB,YAAA,QAAQ,EAAEC,mBAAS,CAACD,qBAAW,CAAC,WAAW,CAAC;AAC5C,YAAA,OAAO,EAAE,OAAO;AAChB,YAAA,WAAW,EAAE,WAAW;AACzB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C,CAAC,CAAC,CAAC,CAAC;AAC3B,aAAA;AAED,YAAA,OAAO,GAAG,CAAC;SACZ,EAAE,EAAE,CAAC,CAAC;AAEP,QAAA,OAAO,UAAU,CAAC;KACnB;IAED,MAAM,uBAAuB,CAAC,YAA+B,EAAA;QAC3D,MAAM,kBAAkB,GAAG,IAAI,CAAC,uBAAuB,CAAC,YAAY,CAAC,CAAC;QACtE,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,OAAO,CAAC,kBAAkB,CAAC,CAAC;QAE9D,IAAI,CAAC,MAAM,EAAE;AACX,YAAA,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;AACpC,SAAA;AAED,QAAA,MAAM,qBAAqB,GAAG,MAAM,CAAC,MAAM,CACzC,CAAC,UAAwB,EAAE,GAAG,EAAE,YAAY,KAAI;AAC9C,YAAA,IAAI,GAAG,EAAE;AACP,gBAAA,UAAU,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,IAAI,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AAClE,aAAA;YAED,IAAI,GAAG,KAAK,IAAI,EAAE;gBAChB,UAAU,CAAC,IAAI,CACb,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,EAAE,QAAQ,CAAC,CAAC,CACrE,CAAC;AACH,aAAA;AAED,YAAA,OAAO,UAAU,CAAC;SACnB,EACD,EAAE,CACH,CAAC;AAEF,QAAA,OAAO,qBAAqB,CAAC;KAC9B;AACF;;;;"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import
|
|
1
|
+
import type _algosdk from "algosdk";
|
|
2
2
|
import { PROVIDER_ID } from "../constants";
|
|
3
3
|
import type { WalletProvider, Asset, Wallet, AccountInfo, ConfirmedTxn, TransactionsArray, TxnInfo } from "../types";
|
|
4
4
|
export interface BaseWalletInterface {
|
|
@@ -6,7 +6,7 @@ export interface BaseWalletInterface {
|
|
|
6
6
|
healthCheck(): Promise<Record<string, never>>;
|
|
7
7
|
disconnect(): Promise<void>;
|
|
8
8
|
reconnect(onDisconnect: () => void): Promise<Wallet | null>;
|
|
9
|
-
decodeTransaction(txn: string, isSigned: boolean):
|
|
9
|
+
decodeTransaction(txn: string, isSigned: boolean): _algosdk.Transaction;
|
|
10
10
|
logEncodedTransaction(txn: string, isSigned: boolean): void;
|
|
11
11
|
groupTransactionsBySender(transactions: TransactionsArray): Record<string, TxnInfo[]>;
|
|
12
12
|
signTransactions(activeAddress: string, transactions: Array<Uint8Array>): Promise<Uint8Array[]>;
|
|
@@ -19,6 +19,8 @@ export interface BaseWalletInterface {
|
|
|
19
19
|
waitForConfirmation(txId: string, timeout?: number): Promise<ConfirmedTxn>;
|
|
20
20
|
}
|
|
21
21
|
declare abstract class BaseWallet implements BaseWalletInterface {
|
|
22
|
+
algosdk: typeof _algosdk;
|
|
23
|
+
algodClient: _algosdk.Algodv2;
|
|
22
24
|
keepWCAlive: HTMLAudioElement;
|
|
23
25
|
protected abstract id: PROVIDER_ID;
|
|
24
26
|
protected abstract provider: WalletProvider;
|
|
@@ -27,7 +29,7 @@ declare abstract class BaseWallet implements BaseWalletInterface {
|
|
|
27
29
|
abstract reconnect(onDisconnect: () => void): Promise<Wallet | null>;
|
|
28
30
|
abstract signTransactions(activeAdress: string, transactions: Array<Uint8Array>): Promise<Uint8Array[]>;
|
|
29
31
|
abstract signEncodedTransactions(transactions: TransactionsArray): Promise<Uint8Array[]>;
|
|
30
|
-
protected constructor();
|
|
32
|
+
protected constructor(algosdk: typeof _algosdk, algodClient: _algosdk.Algodv2);
|
|
31
33
|
healthCheck(): Promise<{}>;
|
|
32
34
|
getAccountInfo(address: string): Promise<AccountInfo>;
|
|
33
35
|
getAssets(address: string): Promise<Asset[]>;
|
|
@@ -41,7 +43,7 @@ declare abstract class BaseWallet implements BaseWalletInterface {
|
|
|
41
43
|
};
|
|
42
44
|
txId: string;
|
|
43
45
|
}>;
|
|
44
|
-
decodeTransaction: (txn: string, isSigned: boolean) =>
|
|
46
|
+
decodeTransaction: (txn: string, isSigned: boolean) => _algosdk.Transaction;
|
|
45
47
|
logEncodedTransaction(txn: string, isSigned: boolean): void;
|
|
46
48
|
groupTransactionsBySender(transactions: TransactionsArray): Record<string, any>;
|
|
47
49
|
sendRawTransactions(transactions: Uint8Array[]): Promise<{
|
|
@@ -1,9 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Helpful resources:
|
|
3
|
+
* https://github.com/blockshake-io/defly-connect
|
|
4
|
+
*/
|
|
5
|
+
import type _algosdk from "algosdk";
|
|
1
6
|
import type { WalletProvider, Wallet } from "../types";
|
|
2
7
|
import { PROVIDER_ID } from "../constants";
|
|
3
8
|
import type { Transaction } from "algosdk";
|
|
4
9
|
import BaseWallet from "./base";
|
|
5
10
|
import { TransactionsArray } from "../types";
|
|
6
|
-
import { DeflyWalletConnect } from "@blockshake/defly-connect";
|
|
11
|
+
import type { DeflyWalletConnect } from "@blockshake/defly-connect";
|
|
7
12
|
export interface DeflyTransaction {
|
|
8
13
|
txn: Transaction;
|
|
9
14
|
/**
|
|
@@ -17,12 +22,14 @@ declare type InitWallet = {
|
|
|
17
22
|
id: PROVIDER_ID;
|
|
18
23
|
client: DeflyWalletConnect;
|
|
19
24
|
provider: WalletProvider;
|
|
25
|
+
algosdk: typeof _algosdk;
|
|
26
|
+
algodClient: _algosdk.Algodv2;
|
|
20
27
|
};
|
|
21
28
|
declare class DeflyWalletClient extends BaseWallet {
|
|
22
29
|
#private;
|
|
23
30
|
id: PROVIDER_ID;
|
|
24
31
|
provider: WalletProvider;
|
|
25
|
-
constructor(
|
|
32
|
+
constructor({ client, id, provider, algosdk, algodClient }: InitWallet);
|
|
26
33
|
static init(): Promise<DeflyWalletClient>;
|
|
27
34
|
connect(onDisconnect: () => void): Promise<Wallet>;
|
|
28
35
|
reconnect(onDisconnect: () => void): Promise<{
|
|
@@ -0,0 +1,159 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var providers = require('../providers.js');
|
|
4
|
+
var base = require('../base-9794b627.js');
|
|
5
|
+
var constants = require('../constants-e76d1f05.js');
|
|
6
|
+
|
|
7
|
+
function _interopNamespace(e) {
|
|
8
|
+
if (e && e.__esModule) return e;
|
|
9
|
+
var n = Object.create(null);
|
|
10
|
+
if (e) {
|
|
11
|
+
Object.keys(e).forEach(function (k) {
|
|
12
|
+
if (k !== 'default') {
|
|
13
|
+
var d = Object.getOwnPropertyDescriptor(e, k);
|
|
14
|
+
Object.defineProperty(n, k, d.get ? d : {
|
|
15
|
+
enumerable: true,
|
|
16
|
+
get: function () { return e[k]; }
|
|
17
|
+
});
|
|
18
|
+
}
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
n["default"] = e;
|
|
22
|
+
return Object.freeze(n);
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
class DeflyWalletClient extends base.BaseWallet {
|
|
26
|
+
#client;
|
|
27
|
+
id;
|
|
28
|
+
provider;
|
|
29
|
+
constructor({ client, id, provider, algosdk, algodClient }) {
|
|
30
|
+
super(algosdk, algodClient);
|
|
31
|
+
this.#client = client;
|
|
32
|
+
this.id = id;
|
|
33
|
+
this.provider = provider;
|
|
34
|
+
}
|
|
35
|
+
static async init() {
|
|
36
|
+
const { algosdk, algodClient } = await base.Algod.init();
|
|
37
|
+
const DeflyWalletConnect = (await Promise.resolve().then(function () { return /*#__PURE__*/_interopNamespace(require('@blockshake/defly-connect')); }))
|
|
38
|
+
.DeflyWalletConnect;
|
|
39
|
+
const deflyWallet = new DeflyWalletConnect({
|
|
40
|
+
shouldShowSignTxnToast: false,
|
|
41
|
+
});
|
|
42
|
+
return new DeflyWalletClient({
|
|
43
|
+
id: constants.PROVIDER_ID.DEFLY,
|
|
44
|
+
client: deflyWallet,
|
|
45
|
+
provider: providers.providers[constants.PROVIDER_ID.DEFLY],
|
|
46
|
+
algosdk,
|
|
47
|
+
algodClient,
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
async connect(onDisconnect) {
|
|
51
|
+
const accounts = await this.#client.connect();
|
|
52
|
+
this.#client.connector?.on("disconnect", onDisconnect);
|
|
53
|
+
if (accounts.length === 0) {
|
|
54
|
+
throw new Error(`No accounts found for ${this.provider}`);
|
|
55
|
+
}
|
|
56
|
+
const mappedAccounts = accounts.map((address, index) => ({
|
|
57
|
+
name: `Defly Wallet ${index + 1}`,
|
|
58
|
+
address,
|
|
59
|
+
providerId: this.provider.id,
|
|
60
|
+
}));
|
|
61
|
+
return {
|
|
62
|
+
...this.provider,
|
|
63
|
+
accounts: mappedAccounts,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
async reconnect(onDisconnect) {
|
|
67
|
+
const accounts = await this.#client.reconnectSession();
|
|
68
|
+
this.#client.connector?.on("disconnect", onDisconnect);
|
|
69
|
+
if (!accounts) {
|
|
70
|
+
return null;
|
|
71
|
+
}
|
|
72
|
+
return {
|
|
73
|
+
...this.provider,
|
|
74
|
+
accounts: accounts.map((address, index) => ({
|
|
75
|
+
name: `Defly Wallet ${index + 1}`,
|
|
76
|
+
address,
|
|
77
|
+
providerId: this.provider.id,
|
|
78
|
+
})),
|
|
79
|
+
};
|
|
80
|
+
}
|
|
81
|
+
async disconnect() {
|
|
82
|
+
await this.#client.disconnect();
|
|
83
|
+
}
|
|
84
|
+
formatTransactionsArray(transactions) {
|
|
85
|
+
const formattedTransactions = [];
|
|
86
|
+
for (const [type, txn] of transactions) {
|
|
87
|
+
if (type === "s") {
|
|
88
|
+
formattedTransactions.push({
|
|
89
|
+
...this.algosdk.decodeSignedTransaction(new Uint8Array(Buffer.from(txn, "base64"))),
|
|
90
|
+
signers: [],
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
else {
|
|
94
|
+
formattedTransactions.push({
|
|
95
|
+
txn: this.algosdk.decodeUnsignedTransaction(new Uint8Array(Buffer.from(txn, "base64"))),
|
|
96
|
+
});
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
return formattedTransactions;
|
|
100
|
+
}
|
|
101
|
+
async signTransactions(activeAdress, transactions) {
|
|
102
|
+
// Decode the transactions to access their properties.
|
|
103
|
+
const decodedTxns = transactions.map((txn) => {
|
|
104
|
+
return this.algosdk.decodeObj(txn);
|
|
105
|
+
});
|
|
106
|
+
// Marshal the transactions,
|
|
107
|
+
// and add the signers property if they shouldn't be signed.
|
|
108
|
+
const txnsToSign = decodedTxns.reduce((acc, txn, i) => {
|
|
109
|
+
if (!("txn" in txn) &&
|
|
110
|
+
this.algosdk.encodeAddress(txn["snd"]) === activeAdress) {
|
|
111
|
+
acc.push({
|
|
112
|
+
txn: this.algosdk.decodeUnsignedTransaction(transactions[i]),
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
else {
|
|
116
|
+
acc.push({
|
|
117
|
+
txn: this.algosdk.decodeSignedTransaction(transactions[i]).txn,
|
|
118
|
+
signers: [],
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
return acc;
|
|
122
|
+
}, []);
|
|
123
|
+
// Sign them with the client.
|
|
124
|
+
const result = await this.#client.signTransaction([txnsToSign]);
|
|
125
|
+
// Join the newly signed transactions with the original group of transactions.
|
|
126
|
+
const signedTxns = decodedTxns.reduce((acc, txn, i) => {
|
|
127
|
+
if (!("txn" in txn)) {
|
|
128
|
+
const signedByUser = result.shift();
|
|
129
|
+
signedByUser && acc.push(signedByUser);
|
|
130
|
+
}
|
|
131
|
+
else {
|
|
132
|
+
acc.push(transactions[i]);
|
|
133
|
+
}
|
|
134
|
+
return acc;
|
|
135
|
+
}, []);
|
|
136
|
+
return signedTxns;
|
|
137
|
+
}
|
|
138
|
+
async signEncodedTransactions(transactions) {
|
|
139
|
+
const transactionsToSign = this.formatTransactionsArray(transactions);
|
|
140
|
+
const result = await this.#client.signTransaction([
|
|
141
|
+
transactionsToSign,
|
|
142
|
+
]);
|
|
143
|
+
const signedTransactions = [];
|
|
144
|
+
let resultIndex = 0;
|
|
145
|
+
for (const [type, txn] of transactions) {
|
|
146
|
+
if (type === "u") {
|
|
147
|
+
signedTransactions.push(result[resultIndex]);
|
|
148
|
+
resultIndex++;
|
|
149
|
+
}
|
|
150
|
+
else {
|
|
151
|
+
signedTransactions.push(new Uint8Array(Buffer.from(txn, "base64")));
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return signedTransactions;
|
|
155
|
+
}
|
|
156
|
+
}
|
|
157
|
+
|
|
158
|
+
module.exports = DeflyWalletClient;
|
|
159
|
+
//# sourceMappingURL=defly.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"defly.js","sources":["../../../src/clients/defly.ts"],"sourcesContent":["/**\n * Helpful resources:\n * https://github.com/blockshake-io/defly-connect\n */\nimport type _algosdk from \"algosdk\";\nimport { providers } from \"../providers\";\nimport Algod from \"../algod\";\nimport type { WalletProvider, Wallet } from \"../types\";\nimport { PROVIDER_ID } from \"../constants\";\nimport type { Transaction } from \"algosdk\";\nimport BaseWallet from \"./base\";\nimport { TransactionsArray } from \"../types\";\nimport type { DeflyWalletConnect } from \"@blockshake/defly-connect\";\nimport type { DecodedTransaction, DecodedSignedTransaction } from \"../types\";\n\nexport interface DeflyTransaction {\n txn: Transaction;\n /**\n * Optional list of addresses that must sign the transactions.\n * Wallet skips to sign this txn if signers is empty array.\n * If undefined, wallet tries to sign it.\n */\n signers?: string[];\n}\n\ntype InitWallet = {\n id: PROVIDER_ID;\n client: DeflyWalletConnect;\n provider: WalletProvider;\n algosdk: typeof _algosdk;\n algodClient: _algosdk.Algodv2;\n};\n\nclass DeflyWalletClient extends BaseWallet {\n #client: DeflyWalletConnect;\n id: PROVIDER_ID;\n provider: WalletProvider;\n\n constructor({ client, id, provider, algosdk, algodClient }: InitWallet) {\n super(algosdk, algodClient);\n\n this.#client = client;\n this.id = id;\n this.provider = provider;\n }\n\n static async init() {\n const { algosdk, algodClient } = await Algod.init();\n\n const DeflyWalletConnect = (await import(\"@blockshake/defly-connect\"))\n .DeflyWalletConnect;\n\n const deflyWallet = new DeflyWalletConnect({\n shouldShowSignTxnToast: false,\n });\n\n return new DeflyWalletClient({\n id: PROVIDER_ID.DEFLY,\n client: deflyWallet,\n provider: providers[PROVIDER_ID.DEFLY],\n algosdk,\n algodClient,\n });\n }\n\n async connect(onDisconnect: () => void): Promise<Wallet> {\n const accounts = await this.#client.connect();\n this.#client.connector?.on(\"disconnect\", onDisconnect);\n\n if (accounts.length === 0) {\n throw new Error(`No accounts found for ${this.provider}`);\n }\n\n const mappedAccounts = accounts.map((address: string, index: number) => ({\n name: `Defly Wallet ${index + 1}`,\n address,\n providerId: this.provider.id,\n }));\n\n return {\n ...this.provider,\n accounts: mappedAccounts,\n };\n }\n\n async reconnect(onDisconnect: () => void) {\n const accounts = await this.#client.reconnectSession();\n this.#client.connector?.on(\"disconnect\", onDisconnect);\n\n if (!accounts) {\n return null;\n }\n\n return {\n ...this.provider,\n accounts: accounts.map((address: string, index: number) => ({\n name: `Defly Wallet ${index + 1}`,\n address,\n providerId: this.provider.id,\n })),\n };\n }\n\n async disconnect() {\n await this.#client.disconnect();\n }\n\n formatTransactionsArray(transactions: TransactionsArray) {\n const formattedTransactions: DeflyTransaction[] = [];\n\n for (const [type, txn] of transactions) {\n if (type === \"s\") {\n formattedTransactions.push({\n ...this.algosdk.decodeSignedTransaction(\n new Uint8Array(Buffer.from(txn, \"base64\"))\n ),\n signers: [],\n });\n } else {\n formattedTransactions.push({\n txn: this.algosdk.decodeUnsignedTransaction(\n new Uint8Array(Buffer.from(txn, \"base64\"))\n ),\n });\n }\n }\n\n return formattedTransactions;\n }\n\n async signTransactions(activeAdress: string, transactions: Uint8Array[]) {\n // Decode the transactions to access their properties.\n const decodedTxns = transactions.map((txn) => {\n return this.algosdk.decodeObj(txn);\n }) as Array<DecodedTransaction | DecodedSignedTransaction>;\n\n // Marshal the transactions,\n // and add the signers property if they shouldn't be signed.\n const txnsToSign = decodedTxns.reduce<DeflyTransaction[]>((acc, txn, i) => {\n if (\n !(\"txn\" in txn) &&\n this.algosdk.encodeAddress(txn[\"snd\"]) === activeAdress\n ) {\n acc.push({\n txn: this.algosdk.decodeUnsignedTransaction(transactions[i]),\n });\n } else {\n acc.push({\n txn: this.algosdk.decodeSignedTransaction(transactions[i]).txn,\n signers: [],\n });\n }\n\n return acc;\n }, []);\n\n // Sign them with the client.\n const result = await this.#client.signTransaction([txnsToSign]);\n\n // Join the newly signed transactions with the original group of transactions.\n const signedTxns = decodedTxns.reduce<Uint8Array[]>((acc, txn, i) => {\n if (!(\"txn\" in txn)) {\n const signedByUser = result.shift();\n signedByUser && acc.push(signedByUser);\n } else {\n acc.push(transactions[i]);\n }\n\n return acc;\n }, []);\n\n return signedTxns;\n }\n\n async signEncodedTransactions(transactions: TransactionsArray) {\n const transactionsToSign = this.formatTransactionsArray(transactions);\n const result: Uint8Array[] = await this.#client.signTransaction([\n transactionsToSign,\n ]);\n\n const signedTransactions: Uint8Array[] = [];\n\n let resultIndex = 0;\n\n for (const [type, txn] of transactions) {\n if (type === \"u\") {\n signedTransactions.push(result[resultIndex]);\n resultIndex++;\n } else {\n signedTransactions.push(new Uint8Array(Buffer.from(txn, \"base64\")));\n }\n }\n\n return signedTransactions;\n }\n}\n\nexport default DeflyWalletClient;\n"],"names":["BaseWallet","Algod","PROVIDER_ID","providers"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAiCA,MAAM,iBAAkB,SAAQA,eAAU,CAAA;AACxC,IAAA,OAAO,CAAqB;AAC5B,IAAA,EAAE,CAAc;AAChB,IAAA,QAAQ,CAAiB;IAEzB,WAAY,CAAA,EAAE,MAAM,EAAE,EAAE,EAAE,QAAQ,EAAE,OAAO,EAAE,WAAW,EAAc,EAAA;AACpE,QAAA,KAAK,CAAC,OAAO,EAAE,WAAW,CAAC,CAAC;AAE5B,QAAA,IAAI,CAAC,OAAO,GAAG,MAAM,CAAC;AACtB,QA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|
* Helpful resources:
|
|
3
3
|
* https://docs.exodus.com/api-reference/algorand-provider-api/
|
|
4
4
|
*/
|
|
5
|
+
import type _algosdk from "algosdk";
|
|
5
6
|
import BaseWallet from "./base";
|
|
6
7
|
import { PROVIDER_ID } from "../constants";
|
|
7
8
|
import type { WalletProvider } from "../types";
|
|
@@ -23,12 +24,14 @@ declare type InitWallet = {
|
|
|
23
24
|
client: Exodus;
|
|
24
25
|
id: PROVIDER_ID;
|
|
25
26
|
provider: WalletProvider;
|
|
27
|
+
algosdk: typeof _algosdk;
|
|
28
|
+
algodClient: _algosdk.Algodv2;
|
|
26
29
|
};
|
|
27
30
|
declare class ExodusClient extends BaseWallet {
|
|
28
31
|
#private;
|
|
29
32
|
id: PROVIDER_ID;
|
|
30
33
|
provider: WalletProvider;
|
|
31
|
-
constructor(
|
|
34
|
+
constructor({ client, id, provider, algosdk, algodClient }: InitWallet);
|
|
32
35
|
static init(): Promise<ExodusClient>;
|
|
33
36
|
connect(): Promise<{
|
|
34
37
|
accounts: {
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
var base = require('../base-9794b627.js');
|
|
4
|
+
var constants = require('../constants-e76d1f05.js');
|
|
5
|
+
var providers = require('../providers.js');
|
|
6
|
+
|
|
7
|
+
class ExodusClient extends base.BaseWallet {
|
|
8
|
+
#client;
|
|
9
|
+
id;
|
|
10
|
+
provider;
|
|
11
|
+
constructor({ client, id, provider, algosdk, algodClient }) {
|
|
12
|
+
super(algosdk, algodClient);
|
|
13
|
+
this.#client = client;
|
|
14
|
+
this.id = id;
|
|
15
|
+
this.provider = provider;
|
|
16
|
+
}
|
|
17
|
+
static async init() {
|
|
18
|
+
if (typeof window == "undefined" ||
|
|
19
|
+
window.exodus === undefined) {
|
|
20
|
+
throw new Error("Exodus is not available.");
|
|
21
|
+
}
|
|
22
|
+
const { algosdk, algodClient } = await base.Algod.init();
|
|
23
|
+
const exodus = window.exodus.algorand;
|
|
24
|
+
return new ExodusClient({
|
|
25
|
+
id: constants.PROVIDER_ID.EXODUS,
|
|
26
|
+
client: exodus,
|
|
27
|
+
provider: providers.providers[constants.PROVIDER_ID.EXODUS],
|
|
28
|
+
algosdk: algosdk,
|
|
29
|
+
algodClient: algodClient,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
async connect() {
|
|
33
|
+
const { address } = await this.#client.connect();
|
|
34
|
+
if (!address) {
|
|
35
|
+
throw new Error(`No accounts found for ${this.provider}`);
|
|
36
|
+
}
|
|
37
|
+
const accounts = [
|
|
38
|
+
{
|
|
39
|
+
name: `Exodus 1`,
|
|
40
|
+
address,
|
|
41
|
+
providerId: this.provider.id,
|
|
42
|
+
},
|
|
43
|
+
];
|
|
44
|
+
return {
|
|
45
|
+
...this.provider,
|
|
46
|
+
accounts,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
async reconnect(onDisconnect) {
|
|
50
|
+
if (window === undefined ||
|
|
51
|
+
window.exodus === undefined ||
|
|
52
|
+
window.exodus.algorand.isConnected !== true) {
|
|
53
|
+
onDisconnect();
|
|
54
|
+
}
|
|
55
|
+
return null;
|
|
56
|
+
}
|
|
57
|
+
async disconnect() {
|
|
58
|
+
return;
|
|
59
|
+
}
|
|
60
|
+
async signTransactions(activeAdress, transactions) {
|
|
61
|
+
// Decode the transactions to access their properties.
|
|
62
|
+
const decodedTxns = transactions.map((txn) => {
|
|
63
|
+
return this.algosdk.decodeObj(txn);
|
|
64
|
+
});
|
|
65
|
+
// Get the unsigned transactions.
|
|
66
|
+
const txnsToSign = decodedTxns.reduce((acc, txn, i) => {
|
|
67
|
+
// If the transaction isn't already signed and is to be sent from a connected account,
|
|
68
|
+
// add it to the arrays of transactions to be signed.
|
|
69
|
+
if (!("txn" in txn) &&
|
|
70
|
+
this.algosdk.encodeAddress(txn["snd"]) === activeAdress) {
|
|
71
|
+
acc.push(transactions[i]);
|
|
72
|
+
}
|
|
73
|
+
return acc;
|
|
74
|
+
}, []);
|
|
75
|
+
// Sign them with the client.
|
|
76
|
+
const result = await this.#client.signTransaction(txnsToSign);
|
|
77
|
+
// Join the newly signed transactions with the original group of transactions.
|
|
78
|
+
const signedTxns = decodedTxns.reduce((acc, txn, i) => {
|
|
79
|
+
if (!("txn" in txn)) {
|
|
80
|
+
const signedByUser = result.shift();
|
|
81
|
+
signedByUser && acc.push(signedByUser);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
acc.push(transactions[i]);
|
|
85
|
+
}
|
|
86
|
+
return acc;
|
|
87
|
+
}, []);
|
|
88
|
+
return signedTxns;
|
|
89
|
+
}
|
|
90
|
+
async signEncodedTransactions(transactions) {
|
|
91
|
+
const transactionsToSign = [];
|
|
92
|
+
const signedRawTransactions = [];
|
|
93
|
+
for (const [type, txn] of transactions) {
|
|
94
|
+
if (type === "u") {
|
|
95
|
+
const decoded = this.algosdk.decodeUnsignedTransaction(Buffer.from(txn, "base64"));
|
|
96
|
+
transactionsToSign.push(decoded.toByte());
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const result = await this.#client.signTransaction(transactionsToSign);
|
|
100
|
+
if (!result) {
|
|
101
|
+
throw new Error("Signing failed.");
|
|
102
|
+
}
|
|
103
|
+
let resultIndex = 0;
|
|
104
|
+
for (const [type, txn] of transactions) {
|
|
105
|
+
if (type === "u") {
|
|
106
|
+
signedRawTransactions.push(result[resultIndex]);
|
|
107
|
+
resultIndex++;
|
|
108
|
+
}
|
|
109
|
+
else {
|
|
110
|
+
signedRawTransactions.push(new Uint8Array(Buffer.from(txn, "base64")));
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
return signedRawTransactions;
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
module.exports = ExodusClient;
|
|
118
|
+
//# sourceMappingURL=exodus.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"exodus.js","sources":["../../../src/clients/exodus.ts"],"sourcesContent":["/**\n * Helpful resources:\n * https://docs.exodus.com/api-reference/algorand-provider-api/\n */\nimport type _algosdk from \"algosdk\";\nimport BaseWallet from \"./base\";\nimport Algod from \"../algod\";\nimport { PROVIDER_ID } from \"../constants\";\nimport { providers } from \"../providers\";\nimport type { WalletProvider } from \"../types\";\nimport { TransactionsArray } from \"../types\";\nimport type { DecodedTransaction, DecodedSignedTransaction } from \"../types\";\n\ntype WindowExtended = { exodus: { algorand: Exodus } } & Window &\n typeof globalThis;\n\ntype Bytes = Readonly<Uint8Array>;\n\ntype Exodus = {\n isConnected: boolean;\n address: string | null;\n connect: () => Promise<{\n address: string;\n }>;\n disconnect: () => void;\n signAndSendTransaction(transactions: Bytes[]): Promise<{\n txId: string;\n }>;\n signTransaction(transactions: Bytes[]): Promise<Bytes[]>;\n};\n\ntype InitWallet = {\n client: Exodus;\n id: PROVIDER_ID;\n provider: WalletProvider;\n algosdk: typeof _algosdk;\n algodClient: _algosdk.Algodv2;\n};\n\nclass ExodusClient extends BaseWallet {\n #client: Exodus;\n id: PROVIDER_ID;\n provider: WalletProvider;\n\n constructor({ client, id, provider, algosdk, algodClient }: InitWallet) {\n super(algosdk, algodClient);\n\n this.#client = client;\n this.id = id;\n this.provider = provider;\n }\n\n static async init() {\n if (\n typeof window == \"undefined\" ||\n (window as WindowExtended).exodus === undefined\n ) {\n throw new Error(\"Exodus is not available.\");\n }\n\n const { algosdk, algodClient } = await Algod.init();\n const exodus = (window as WindowExtended).exodus.algorand as Exodus;\n\n return new ExodusClient({\n id: PROVIDER_ID.EXODUS,\n client: exodus,\n provider: providers[PROVIDER_ID.EXODUS],\n algosdk: algosdk,\n algodClient: algodClient,\n });\n }\n\n async connect() {\n const { address } = await this.#client.connect();\n\n if (!address) {\n throw new Error(`No accounts found for ${this.provider}`);\n }\n\n const accounts = [\n {\n name: `Exodus 1`,\n address,\n providerId: this.provider.id,\n },\n ];\n\n return {\n ...this.provider,\n accounts,\n };\n }\n\n async reconnect(onDisconnect: () => void) {\n if (\n window === undefined ||\n (window as WindowExtended).exodus === undefined ||\n (window as WindowExtended).exodus.algorand.isConnected !== true\n ) {\n onDisconnect();\n }\n\n return null;\n }\n\n async disconnect() {\n return;\n }\n\n async signTransactions(\n activeAdress: string,\n transactions: Array<Uint8Array>\n ) {\n // Decode the transactions to access their properties.\n const decodedTxns = transactions.map((txn) => {\n return this.algosdk.decodeObj(txn);\n }) as Array<DecodedTransaction | DecodedSignedTransaction>;\n\n // Get the unsigned transactions.\n const txnsToSign = decodedTxns.reduce<Uint8Array[]>((acc, txn, i) => {\n // If the transaction isn't already signed and is to be sent from a connected account,\n // add it to the arrays of transactions to be signed.\n if (\n !(\"txn\" in txn) &&\n this.algosdk.encodeAddress(txn[\"snd\"]) === activeAdress\n ) {\n acc.push(transactions[i]);\n }\n\n return acc;\n }, []);\n\n // Sign them with the client.\n const result = await this.#client.signTransaction(txnsToSign);\n\n // Join the newly signed transactions with the original group of transactions.\n const signedTxns = decodedTxns.reduce<Uint8Array[]>((acc, txn, i) => {\n if (!(\"txn\" in txn)) {\n const signedByUser = result.shift();\n signedByUser && acc.push(signedByUser);\n } else {\n acc.push(transactions[i]);\n }\n\n return acc;\n }, []);\n\n return signedTxns;\n }\n\n async signEncodedTransactions(transactions: TransactionsArray) {\n const transactionsToSign: Uint8Array[] = [];\n const signedRawTransactions: Uint8Array[] = [];\n\n for (const [type, txn] of transactions) {\n if (type === \"u\") {\n const decoded = this.algosdk.decodeUnsignedTransaction(\n Buffer.from(txn, \"base64\")\n );\n transactionsToSign.push(decoded.toByte());\n }\n }\n\n const result = await this.#client.signTransaction(transactionsToSign);\n\n if (!result) {\n throw new Error(\"Signing failed.\");\n }\n\n let resultIndex = 0;\n\n for (const [type, txn] of transactions) {\n if (type === \"u\") {\n signedRawTransactions.push(result[resultIndex]);\n resultIndex++;\n } else {\n signedRawTransactions.push(new Uint8Array(Buffer.from(txn, \"base64\")));\n }\n }\n\n return signedRawTransactions;\n }\n}\n\nexport default ExodusClient;\n"],"names":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AI,EAAE,GAAG,CAAC,IAAI,YAAY,EAAE;YACtC,IAAI,IAAI,KAAK,GAAG,EAAE;gBAChB,qBAAqB,CAAC,IAAI,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC;AAChD,gBAAA,WAAW,EAAE,CAAC;AACf,aAAA;AAAM,iBAAA;AACL,gBAAA,qBAAqB,CAAC,IAAI,CAAC,IAAI,UAAU,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,EAAE,QAAQ,CAAC,CAAC,CAAC,CAAC;AACxE,aAAA;AACF,SAAA;AAED,QAAA,OAAO,qBAAqB,CAAC;KAC9B;AACF;;;;"}
|
|
@@ -6,11 +6,11 @@ import exodusClient from "./exodus";
|
|
|
6
6
|
import kmdClient from "./kmd";
|
|
7
7
|
import walletconnectClient from "./walletconnect";
|
|
8
8
|
export declare const clients: {
|
|
9
|
-
"KMD Wallet":
|
|
10
|
-
"Pera Wallet":
|
|
11
|
-
"MyAlgo Wallet":
|
|
12
|
-
"Algo Signer":
|
|
13
|
-
Defly:
|
|
14
|
-
Exodus:
|
|
15
|
-
"Wallet Connect":
|
|
9
|
+
"KMD Wallet": Promise<void | kmdClient>;
|
|
10
|
+
"Pera Wallet": Promise<void | peraWalletClient>;
|
|
11
|
+
"MyAlgo Wallet": Promise<void | myAlgoWalletClient>;
|
|
12
|
+
"Algo Signer": Promise<void | algoSignerClient>;
|
|
13
|
+
Defly: Promise<void | deflyClient>;
|
|
14
|
+
Exodus: Promise<void | exodusClient>;
|
|
15
|
+
"Wallet Connect": Promise<void | walletconnectClient>;
|
|
16
16
|
};
|
|
@@ -1,19 +1,21 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import type _algosdk from "algosdk";
|
|
2
2
|
import BaseWallet from "./base";
|
|
3
3
|
import { PROVIDER_ID } from "../constants";
|
|
4
4
|
import type { Account, Wallet, WalletProvider } from "../types";
|
|
5
5
|
import { TransactionsArray } from "../types";
|
|
6
6
|
declare type InitWallet = {
|
|
7
|
-
client: Kmd;
|
|
7
|
+
client: _algosdk.Kmd;
|
|
8
8
|
id: PROVIDER_ID;
|
|
9
9
|
provider: WalletProvider;
|
|
10
|
+
algosdk: typeof _algosdk;
|
|
11
|
+
algodClient: _algosdk.Algodv2;
|
|
10
12
|
};
|
|
11
13
|
declare class KMDWallet extends BaseWallet {
|
|
12
14
|
#private;
|
|
13
15
|
walletId: string;
|
|
14
16
|
id: PROVIDER_ID;
|
|
15
17
|
provider: WalletProvider;
|
|
16
|
-
constructor(
|
|
18
|
+
constructor({ client, id, provider, algosdk, algodClient }: InitWallet);
|
|
17
19
|
static init(): Promise<KMDWallet>;
|
|
18
20
|
connect(): Promise<Wallet>;
|
|
19
21
|
disconnect(): Promise<void>;
|