@txnlab/use-wallet-kibisis 5.0.0-rc.1
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/LICENSE +21 -0
- package/dist/index.d.ts +84 -0
- package/dist/index.js +328 -0
- package/dist/index.js.map +1 -0
- package/package.json +49 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 TxnLab, Inc.
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import algosdk from "algosdk";
|
|
2
|
+
import { AdapterConstructorParams, BaseWallet, WalletAccount, WalletMetadata } from "@txnlab/use-wallet/adapter";
|
|
3
|
+
import AVMWebProviderSDK from "@agoralabs-sh/avm-web-provider";
|
|
4
|
+
import { WalletAdapterConfig } from "@txnlab/use-wallet";
|
|
5
|
+
|
|
6
|
+
//#region src/avm-provider.d.ts
|
|
7
|
+
declare abstract class AVMProvider extends BaseWallet {
|
|
8
|
+
avmWebClient: AVMWebProviderSDK.AVMWebClient | null;
|
|
9
|
+
protected avmWebProviderSDK: typeof AVMWebProviderSDK | null;
|
|
10
|
+
protected providerId: string;
|
|
11
|
+
constructor(params: AdapterConstructorParams & {
|
|
12
|
+
providerId: string;
|
|
13
|
+
});
|
|
14
|
+
protected _initializeAVMWebProviderSDK(): Promise<typeof AVMWebProviderSDK>;
|
|
15
|
+
protected _initializeAVMWebClient(): Promise<AVMWebProviderSDK.AVMWebClient>;
|
|
16
|
+
protected _getGenesisHash(): Promise<string>;
|
|
17
|
+
protected _mapAVMWebProviderAccountToWalletAccounts(accounts: AVMWebProviderSDK.IAccount[]): WalletAccount[];
|
|
18
|
+
protected processTxns(txnGroup: algosdk.Transaction[], indexesToSign?: number[]): AVMWebProviderSDK.IARC0001Transaction[];
|
|
19
|
+
protected processEncodedTxns(txnGroup: Uint8Array[], indexesToSign?: number[]): AVMWebProviderSDK.IARC0001Transaction[];
|
|
20
|
+
/**
|
|
21
|
+
* Abstract methods
|
|
22
|
+
* These methods must be implemented by specific wallet providers
|
|
23
|
+
*/
|
|
24
|
+
protected abstract _enable(): Promise<AVMWebProviderSDK.IEnableResult>;
|
|
25
|
+
protected abstract _disable(): Promise<AVMWebProviderSDK.IDisableResult>;
|
|
26
|
+
protected abstract _signTransactions(txns: AVMWebProviderSDK.IARC0001Transaction[]): Promise<AVMWebProviderSDK.ISignTransactionsResult>;
|
|
27
|
+
/**
|
|
28
|
+
* Common methods
|
|
29
|
+
* These methods can be overridden by specific wallet providers if needed
|
|
30
|
+
*/
|
|
31
|
+
connect(): Promise<WalletAccount[]>;
|
|
32
|
+
disconnect(): Promise<void>;
|
|
33
|
+
resumeSession(): Promise<void>;
|
|
34
|
+
signTransactions<T extends algosdk.Transaction[] | Uint8Array[]>(txnGroup: T | T[], indexesToSign?: number[]): Promise<(Uint8Array | null)[]>;
|
|
35
|
+
}
|
|
36
|
+
//#endregion
|
|
37
|
+
//#region src/adapter.d.ts
|
|
38
|
+
declare class KibisisAdapter extends AVMProvider {
|
|
39
|
+
constructor(params: AdapterConstructorParams);
|
|
40
|
+
static defaultMetadata: WalletMetadata;
|
|
41
|
+
/**
|
|
42
|
+
* Calls the "enable" method on the provider. This method will timeout after 3 minutes.
|
|
43
|
+
* @returns {Promise<AVMWebProviderSDK.IEnableResult>} a promise that resolves to the result.
|
|
44
|
+
* @protected
|
|
45
|
+
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
46
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
47
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
48
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
49
|
+
* @throws {UnknownError} if the response result is empty.
|
|
50
|
+
*/
|
|
51
|
+
protected _enable(): Promise<AVMWebProviderSDK.IEnableResult>;
|
|
52
|
+
/**
|
|
53
|
+
* Calls the "disable" method on the provider. This method will timeout after 0.75 seconds.
|
|
54
|
+
* @returns {Promise<AVMWebProviderSDK.IDisableResult>} a promise that resolves to the result.
|
|
55
|
+
* @protected
|
|
56
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
57
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
58
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
59
|
+
* @throws {UnknownError} if the response result is empty.
|
|
60
|
+
*/
|
|
61
|
+
protected _disable(): Promise<AVMWebProviderSDK.IDisableResult>;
|
|
62
|
+
/**
|
|
63
|
+
* Calls the "signTransactions" method to sign the supplied ARC-0001 transactions. This method
|
|
64
|
+
* will timeout after 3 minutes.
|
|
65
|
+
* @returns {Promise<AVMWebProviderSDK.ISignTransactionsResult>} a promise that resolves to the result.
|
|
66
|
+
* @protected
|
|
67
|
+
* @throws {InvalidInputError} if computed group ID for the txns does not match the assigned group ID.
|
|
68
|
+
* @throws {InvalidGroupIdError} if the unsigned txns is malformed or not conforming to ARC-0001.
|
|
69
|
+
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
70
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
71
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
72
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
73
|
+
* @throws {UnauthorizedSignerError} if a signer in the request is not authorized by the provider.
|
|
74
|
+
* @throws {UnknownError} if the response result is empty.
|
|
75
|
+
*/
|
|
76
|
+
protected _signTransactions(txns: AVMWebProviderSDK.IARC0001Transaction[]): Promise<AVMWebProviderSDK.ISignTransactionsResult>;
|
|
77
|
+
}
|
|
78
|
+
//#endregion
|
|
79
|
+
//#region src/index.d.ts
|
|
80
|
+
declare const WALLET_ID: "kibisis";
|
|
81
|
+
declare function kibisis(): WalletAdapterConfig;
|
|
82
|
+
//#endregion
|
|
83
|
+
export { KibisisAdapter, WALLET_ID, kibisis };
|
|
84
|
+
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,328 @@
|
|
|
1
|
+
import algosdk from "algosdk";
|
|
2
|
+
import { BaseWallet, base64ToByteArray, byteArrayToBase64, compareAccounts, flattenTxnGroup, isSignedTxn, isTransactionArray } from "@txnlab/use-wallet/adapter";
|
|
3
|
+
//#region src/avm-provider.ts
|
|
4
|
+
function isAVMWebProviderSDKError(error) {
|
|
5
|
+
return typeof error === "object" && "code" in error && "message" in error;
|
|
6
|
+
}
|
|
7
|
+
var AVMProvider = class extends BaseWallet {
|
|
8
|
+
avmWebClient = null;
|
|
9
|
+
avmWebProviderSDK = null;
|
|
10
|
+
providerId;
|
|
11
|
+
constructor(params) {
|
|
12
|
+
super(params);
|
|
13
|
+
this.providerId = params.providerId;
|
|
14
|
+
}
|
|
15
|
+
async _initializeAVMWebProviderSDK() {
|
|
16
|
+
if (!this.avmWebProviderSDK) {
|
|
17
|
+
this.logger.info("Initializing @agoralabs-sh/avm-web-provider...");
|
|
18
|
+
const module = await import("@agoralabs-sh/avm-web-provider");
|
|
19
|
+
this.avmWebProviderSDK = module.default ? module.default : module;
|
|
20
|
+
if (!this.avmWebProviderSDK) throw new Error("Failed to initialize, the @agoralabs-sh/avm-web-provider SDK was not provided");
|
|
21
|
+
if (!this.avmWebProviderSDK.AVMWebClient) throw new Error("Failed to initialize, AVMWebClient missing from @agoralabs-sh/avm-web-provider SDK");
|
|
22
|
+
this.logger.info("@agoralabs-sh/avm-web-provider SDK initialized");
|
|
23
|
+
}
|
|
24
|
+
return this.avmWebProviderSDK;
|
|
25
|
+
}
|
|
26
|
+
async _initializeAVMWebClient() {
|
|
27
|
+
const avmWebProviderSDK = await this._initializeAVMWebProviderSDK();
|
|
28
|
+
if (!avmWebProviderSDK.AVMWebClient) throw new Error("Failed to initialize, AVMWebClient not found");
|
|
29
|
+
if (!this.avmWebClient) {
|
|
30
|
+
this.logger.info("Initializing new AVM Web Client...");
|
|
31
|
+
this.avmWebClient = avmWebProviderSDK.AVMWebClient.init();
|
|
32
|
+
this.logger.info("AVM Web Client initialized");
|
|
33
|
+
}
|
|
34
|
+
return this.avmWebClient;
|
|
35
|
+
}
|
|
36
|
+
async _getGenesisHash() {
|
|
37
|
+
const network = this.activeNetworkConfig;
|
|
38
|
+
if (network.genesisHash) return network.genesisHash;
|
|
39
|
+
const version = await this.getAlgodClient().versionsCheck().do();
|
|
40
|
+
return algosdk.bytesToBase64(version.genesisHashB64);
|
|
41
|
+
}
|
|
42
|
+
_mapAVMWebProviderAccountToWalletAccounts(accounts) {
|
|
43
|
+
return accounts.map(({ address, name }, idx) => ({
|
|
44
|
+
name: name || `[${this.metadata.name}] Account ${idx + 1}`,
|
|
45
|
+
address
|
|
46
|
+
}));
|
|
47
|
+
}
|
|
48
|
+
processTxns(txnGroup, indexesToSign) {
|
|
49
|
+
const txnsToSign = [];
|
|
50
|
+
txnGroup.forEach((txn, index) => {
|
|
51
|
+
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
52
|
+
const signer = txn.sender.toString();
|
|
53
|
+
const canSignTxn = this.addresses.includes(signer);
|
|
54
|
+
const txnString = byteArrayToBase64(txn.toByte());
|
|
55
|
+
if (isIndexMatch && canSignTxn) txnsToSign.push({ txn: txnString });
|
|
56
|
+
else txnsToSign.push({
|
|
57
|
+
txn: txnString,
|
|
58
|
+
signers: []
|
|
59
|
+
});
|
|
60
|
+
});
|
|
61
|
+
return txnsToSign;
|
|
62
|
+
}
|
|
63
|
+
processEncodedTxns(txnGroup, indexesToSign) {
|
|
64
|
+
const txnsToSign = [];
|
|
65
|
+
txnGroup.forEach((txnBuffer, index) => {
|
|
66
|
+
const isSigned = isSignedTxn(algosdk.msgpackRawDecode(txnBuffer));
|
|
67
|
+
const txn = isSigned ? algosdk.decodeSignedTransaction(txnBuffer).txn : algosdk.decodeUnsignedTransaction(txnBuffer);
|
|
68
|
+
const isIndexMatch = !indexesToSign || indexesToSign.includes(index);
|
|
69
|
+
const signer = txn.sender.toString();
|
|
70
|
+
const canSignTxn = !isSigned && this.addresses.includes(signer);
|
|
71
|
+
const txnString = byteArrayToBase64(txn.toByte());
|
|
72
|
+
if (isIndexMatch && canSignTxn) txnsToSign.push({ txn: txnString });
|
|
73
|
+
else txnsToSign.push({
|
|
74
|
+
txn: txnString,
|
|
75
|
+
signers: []
|
|
76
|
+
});
|
|
77
|
+
});
|
|
78
|
+
return txnsToSign;
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* Common methods
|
|
82
|
+
* These methods can be overridden by specific wallet providers if needed
|
|
83
|
+
*/
|
|
84
|
+
async connect() {
|
|
85
|
+
try {
|
|
86
|
+
this.logger.info("Connecting...");
|
|
87
|
+
const result = await this._enable();
|
|
88
|
+
this.logger.info(`Successfully connected on network "${result.genesisId}"`);
|
|
89
|
+
const walletAccounts = this._mapAVMWebProviderAccountToWalletAccounts(result.accounts);
|
|
90
|
+
const walletState = {
|
|
91
|
+
accounts: walletAccounts,
|
|
92
|
+
activeAccount: walletAccounts[0]
|
|
93
|
+
};
|
|
94
|
+
this.store.addWallet(walletState);
|
|
95
|
+
this.logger.info("Connected.", walletState);
|
|
96
|
+
return walletAccounts;
|
|
97
|
+
} catch (error) {
|
|
98
|
+
this.logger.error("Error connecting: ", isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message);
|
|
99
|
+
throw error;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
async disconnect() {
|
|
103
|
+
try {
|
|
104
|
+
this.logger.info("Disconnecting...");
|
|
105
|
+
this.onDisconnect();
|
|
106
|
+
const result = await this._disable();
|
|
107
|
+
this.logger.info(`Successfully disconnected${result.sessionIds && result.sessionIds.length ? ` sessions [${result.sessionIds.join(",")}]` : ""} on network "${result.genesisId}"`);
|
|
108
|
+
} catch (error) {
|
|
109
|
+
this.logger.error("Error disconnecting: ", isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message);
|
|
110
|
+
throw error;
|
|
111
|
+
}
|
|
112
|
+
}
|
|
113
|
+
async resumeSession() {
|
|
114
|
+
const walletState = this.store.getWalletState();
|
|
115
|
+
if (!walletState) {
|
|
116
|
+
this.logger.info("No session to resume");
|
|
117
|
+
return;
|
|
118
|
+
}
|
|
119
|
+
try {
|
|
120
|
+
this.logger.info("Resuming session...");
|
|
121
|
+
const result = await this._enable();
|
|
122
|
+
if (result.accounts.length === 0) throw new Error("No accounts found!");
|
|
123
|
+
const walletAccounts = this._mapAVMWebProviderAccountToWalletAccounts(result.accounts);
|
|
124
|
+
if (!compareAccounts(walletAccounts, walletState.accounts)) {
|
|
125
|
+
this.logger.warn("Session accounts mismatch, updating accounts", {
|
|
126
|
+
prev: walletState.accounts,
|
|
127
|
+
current: walletAccounts
|
|
128
|
+
});
|
|
129
|
+
this.store.setAccounts(walletAccounts);
|
|
130
|
+
}
|
|
131
|
+
this.logger.info("Session resumed successfully");
|
|
132
|
+
} catch (error) {
|
|
133
|
+
this.logger.error("Error resuming session: ", isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message);
|
|
134
|
+
this.onDisconnect();
|
|
135
|
+
throw error;
|
|
136
|
+
}
|
|
137
|
+
}
|
|
138
|
+
async signTransactions(txnGroup, indexesToSign) {
|
|
139
|
+
try {
|
|
140
|
+
this.logger.debug("Signing transactions...", {
|
|
141
|
+
txnGroup,
|
|
142
|
+
indexesToSign
|
|
143
|
+
});
|
|
144
|
+
let txnsToSign = [];
|
|
145
|
+
if (isTransactionArray(txnGroup)) {
|
|
146
|
+
const flatTxns = flattenTxnGroup(txnGroup);
|
|
147
|
+
txnsToSign = this.processTxns(flatTxns, indexesToSign);
|
|
148
|
+
} else {
|
|
149
|
+
const flatTxns = flattenTxnGroup(txnGroup);
|
|
150
|
+
txnsToSign = this.processEncodedTxns(flatTxns, indexesToSign);
|
|
151
|
+
}
|
|
152
|
+
this.logger.debug("Sending processed transactions to wallet...", txnsToSign);
|
|
153
|
+
const signTxnsResult = await this._signTransactions(txnsToSign);
|
|
154
|
+
this.logger.debug("Received signed transactions from wallet", signTxnsResult);
|
|
155
|
+
const result = signTxnsResult.stxns.map((value) => {
|
|
156
|
+
if (value === null) return null;
|
|
157
|
+
return base64ToByteArray(value);
|
|
158
|
+
});
|
|
159
|
+
this.logger.debug("Transactions signed successfully", result);
|
|
160
|
+
return result;
|
|
161
|
+
} catch (error) {
|
|
162
|
+
this.logger.error("Error signing transactions: ", isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message);
|
|
163
|
+
throw error;
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
};
|
|
167
|
+
//#endregion
|
|
168
|
+
//#region src/icon.ts
|
|
169
|
+
const icon = `
|
|
170
|
+
<svg viewBox="0 0 480 480" xmlns="http://www.w3.org/2000/svg">
|
|
171
|
+
<rect fill="#801C96" width="480" height="480" />
|
|
172
|
+
<path fill="#FFFFFF" d="M393.5,223.2c0-7.3-0.6-14.6-1.6-21.6c-0.9-6.5-2.3-12.8-4-18.9c-18-64.9-77.4-112.5-148-112.5c-70.6,0-130,47.6-148,112.5c-1.7,6.2-3,12.5-4,19c-1,7.1-1.6,14.3-1.6,21.6h0v85.5h19.7v-85.5c0-7.2,0.6-14.4,1.8-21.4c14,1.1,27.6,4.3,40.5,9.5c15.9,6.4,30.3,15.6,42.6,27.3c12.3,11.7,22,25.4,28.7,40.6c6.9,15.6,10.5,32.2,10.5,49.2v81.4h0.1h19.6h0.1v-81.5c0.1-17.1,3.6-33.7,10.5-49.2c6.7-15.2,16.4-28.8,28.7-40.6c4.2-4,8.6-7.7,13.2-11.1v132.2h19.7V223.2h0c0-2.5-0.1-5-0.4-7.4c3.3-1.6,6.6-3.1,10-4.5c12.9-5.2,26.4-8.4,40.4-9.5c1.2,7,1.7,14.2,1.8,21.4v85.5h19.7L393.5,223.2L393.5,223.2z M240.1,277.3c-11.6-29.3-32.7-54.1-59.8-71c2.9-10,8.2-19.1,15.8-26.6c11.8-11.8,27.4-18.2,44-18.2s32.3,6.5,44,18.2c4.1,4.1,7.5,8.7,10.3,13.6c5.6-3.4,11.4-6.4,17.4-9.2c-14-25.2-40.9-42.3-71.8-42.3c-35.9,0-66.3,23-77.5,55.1c-15.5-7.1-32.5-11.8-50.4-13.5c1.3-4,2.7-7.9,4.3-11.8c6.7-15.9,16.4-30.3,28.7-42.6s26.6-22,42.6-28.7c16.5-7,34-10.5,52.1-10.5s35.6,3.5,52.1,10.5c15.9,6.7,30.3,16.4,42.6,28.7s22,26.6,28.7,42.6c1.6,3.9,3.1,7.8,4.3,11.8C309,189.2,260.1,226.5,240.1,277.3z" />
|
|
173
|
+
<path fill="#FFFFFF" d="M158.1,359.8h19.7V245.5c-6.1-5.4-12.7-10-19.7-14V359.8z" />
|
|
174
|
+
</svg>
|
|
175
|
+
`;
|
|
176
|
+
//#endregion
|
|
177
|
+
//#region src/adapter.ts
|
|
178
|
+
const PROVIDER_ID = "f6d1c86b-4493-42fb-b88d-a62407b4cdf6";
|
|
179
|
+
const ICON = `data:image/svg+xml;base64,${btoa(icon)}`;
|
|
180
|
+
var KibisisAdapter = class extends AVMProvider {
|
|
181
|
+
constructor(params) {
|
|
182
|
+
super({
|
|
183
|
+
...params,
|
|
184
|
+
providerId: PROVIDER_ID
|
|
185
|
+
});
|
|
186
|
+
}
|
|
187
|
+
static defaultMetadata = {
|
|
188
|
+
name: "Kibisis",
|
|
189
|
+
icon: ICON
|
|
190
|
+
};
|
|
191
|
+
/**
|
|
192
|
+
* Calls the "enable" method on the provider. This method will timeout after 3 minutes.
|
|
193
|
+
* @returns {Promise<AVMWebProviderSDK.IEnableResult>} a promise that resolves to the result.
|
|
194
|
+
* @protected
|
|
195
|
+
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
196
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
197
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
198
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
199
|
+
* @throws {UnknownError} if the response result is empty.
|
|
200
|
+
*/
|
|
201
|
+
async _enable() {
|
|
202
|
+
const { ARC0027MethodEnum, ARC0027MethodTimedOutError, ARC0027UnknownError, DEFAULT_REQUEST_TIMEOUT } = await this._initializeAVMWebProviderSDK();
|
|
203
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
204
|
+
const genesisHash = await this._getGenesisHash();
|
|
205
|
+
return new Promise((resolve, reject) => {
|
|
206
|
+
const timerId = window.setTimeout(() => {
|
|
207
|
+
avmWebClient.removeListener(listenerId);
|
|
208
|
+
reject(new ARC0027MethodTimedOutError({
|
|
209
|
+
method: ARC0027MethodEnum.Enable,
|
|
210
|
+
message: `no response from provider "${this.metadata.name}"`,
|
|
211
|
+
providerId: PROVIDER_ID
|
|
212
|
+
}));
|
|
213
|
+
}, DEFAULT_REQUEST_TIMEOUT);
|
|
214
|
+
const listenerId = avmWebClient.onEnable(({ error, method, result }) => {
|
|
215
|
+
avmWebClient.removeListener(listenerId);
|
|
216
|
+
window.clearTimeout(timerId);
|
|
217
|
+
if (error) return reject(error);
|
|
218
|
+
if (!result) return reject(new ARC0027UnknownError({
|
|
219
|
+
message: `received response, but "${method}" request details were empty for provider "${this.metadata.name}"`,
|
|
220
|
+
providerId: PROVIDER_ID
|
|
221
|
+
}));
|
|
222
|
+
return resolve(result);
|
|
223
|
+
});
|
|
224
|
+
avmWebClient.enable({
|
|
225
|
+
genesisHash,
|
|
226
|
+
providerId: PROVIDER_ID
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
}
|
|
230
|
+
/**
|
|
231
|
+
* Calls the "disable" method on the provider. This method will timeout after 0.75 seconds.
|
|
232
|
+
* @returns {Promise<AVMWebProviderSDK.IDisableResult>} a promise that resolves to the result.
|
|
233
|
+
* @protected
|
|
234
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
235
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
236
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
237
|
+
* @throws {UnknownError} if the response result is empty.
|
|
238
|
+
*/
|
|
239
|
+
async _disable() {
|
|
240
|
+
const { ARC0027MethodEnum, ARC0027MethodTimedOutError, ARC0027UnknownError, LOWER_REQUEST_TIMEOUT } = await this._initializeAVMWebProviderSDK();
|
|
241
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
242
|
+
const genesisHash = await this._getGenesisHash();
|
|
243
|
+
return new Promise((resolve, reject) => {
|
|
244
|
+
const timerId = window.setTimeout(() => {
|
|
245
|
+
avmWebClient.removeListener(listenerId);
|
|
246
|
+
reject(new ARC0027MethodTimedOutError({
|
|
247
|
+
method: ARC0027MethodEnum.Disable,
|
|
248
|
+
message: `no response from provider "${this.metadata.name}"`,
|
|
249
|
+
providerId: PROVIDER_ID
|
|
250
|
+
}));
|
|
251
|
+
}, LOWER_REQUEST_TIMEOUT);
|
|
252
|
+
const listenerId = avmWebClient.onDisable(({ error, method, result }) => {
|
|
253
|
+
avmWebClient.removeListener(listenerId);
|
|
254
|
+
window.clearTimeout(timerId);
|
|
255
|
+
if (error) return reject(error);
|
|
256
|
+
if (!result) return reject(new ARC0027UnknownError({
|
|
257
|
+
message: `received response, but "${method}" request details were empty for provider "${this.metadata.name}"`,
|
|
258
|
+
providerId: PROVIDER_ID
|
|
259
|
+
}));
|
|
260
|
+
this.logger.debug("Disable successful", { result });
|
|
261
|
+
return resolve(result);
|
|
262
|
+
});
|
|
263
|
+
this.logger.debug("Sending disable request...", { genesisHash });
|
|
264
|
+
avmWebClient.disable({
|
|
265
|
+
genesisHash,
|
|
266
|
+
providerId: PROVIDER_ID
|
|
267
|
+
});
|
|
268
|
+
});
|
|
269
|
+
}
|
|
270
|
+
/**
|
|
271
|
+
* Calls the "signTransactions" method to sign the supplied ARC-0001 transactions. This method
|
|
272
|
+
* will timeout after 3 minutes.
|
|
273
|
+
* @returns {Promise<AVMWebProviderSDK.ISignTransactionsResult>} a promise that resolves to the result.
|
|
274
|
+
* @protected
|
|
275
|
+
* @throws {InvalidInputError} if computed group ID for the txns does not match the assigned group ID.
|
|
276
|
+
* @throws {InvalidGroupIdError} if the unsigned txns is malformed or not conforming to ARC-0001.
|
|
277
|
+
* @throws {MethodCanceledError} if the method was cancelled by the user.
|
|
278
|
+
* @throws {MethodNotSupportedError} if the method is not supported for the configured network.
|
|
279
|
+
* @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).
|
|
280
|
+
* @throws {NetworkNotSupportedError} if the network is not supported for the configured network.
|
|
281
|
+
* @throws {UnauthorizedSignerError} if a signer in the request is not authorized by the provider.
|
|
282
|
+
* @throws {UnknownError} if the response result is empty.
|
|
283
|
+
*/
|
|
284
|
+
async _signTransactions(txns) {
|
|
285
|
+
const { ARC0027MethodEnum, ARC0027MethodTimedOutError, ARC0027UnknownError, DEFAULT_REQUEST_TIMEOUT } = await this._initializeAVMWebProviderSDK();
|
|
286
|
+
const avmWebClient = await this._initializeAVMWebClient();
|
|
287
|
+
return new Promise((resolve, reject) => {
|
|
288
|
+
const timerId = window.setTimeout(() => {
|
|
289
|
+
avmWebClient.removeListener(listenerId);
|
|
290
|
+
reject(new ARC0027MethodTimedOutError({
|
|
291
|
+
method: ARC0027MethodEnum.SignTransactions,
|
|
292
|
+
message: `no response from provider "${this.metadata.name}"`,
|
|
293
|
+
providerId: PROVIDER_ID
|
|
294
|
+
}));
|
|
295
|
+
}, DEFAULT_REQUEST_TIMEOUT);
|
|
296
|
+
const listenerId = avmWebClient.onSignTransactions(({ error, method, result }) => {
|
|
297
|
+
avmWebClient.removeListener(listenerId);
|
|
298
|
+
window.clearTimeout(timerId);
|
|
299
|
+
if (error) return reject(error);
|
|
300
|
+
if (!result) return reject(new ARC0027UnknownError({
|
|
301
|
+
message: `received response, but "${method}" request details were empty for provider "${this.metadata.name}"`,
|
|
302
|
+
providerId: PROVIDER_ID
|
|
303
|
+
}));
|
|
304
|
+
this.logger.debug("Sign transactions successful", { result });
|
|
305
|
+
return resolve(result);
|
|
306
|
+
});
|
|
307
|
+
this.logger.debug("Sending sign transactions request...", { txns });
|
|
308
|
+
avmWebClient.signTransactions({
|
|
309
|
+
txns,
|
|
310
|
+
providerId: PROVIDER_ID
|
|
311
|
+
});
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
};
|
|
315
|
+
//#endregion
|
|
316
|
+
//#region src/index.ts
|
|
317
|
+
const WALLET_ID = "kibisis";
|
|
318
|
+
function kibisis() {
|
|
319
|
+
return {
|
|
320
|
+
id: WALLET_ID,
|
|
321
|
+
metadata: KibisisAdapter.defaultMetadata,
|
|
322
|
+
Adapter: KibisisAdapter
|
|
323
|
+
};
|
|
324
|
+
}
|
|
325
|
+
//#endregion
|
|
326
|
+
export { KibisisAdapter, WALLET_ID, kibisis };
|
|
327
|
+
|
|
328
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","names":[],"sources":["../src/avm-provider.ts","../src/icon.ts","../src/adapter.ts","../src/index.ts"],"sourcesContent":["import algosdk from 'algosdk'\nimport {\n BaseWallet,\n base64ToByteArray,\n byteArrayToBase64,\n compareAccounts,\n flattenTxnGroup,\n isSignedTxn,\n isTransactionArray,\n type AdapterConstructorParams,\n type WalletAccount,\n type WalletState\n} from '@txnlab/use-wallet/adapter'\nimport type AVMWebProviderSDK from '@agoralabs-sh/avm-web-provider'\n\nexport function isAVMWebProviderSDKError(error: any): error is AVMWebProviderSDK.BaseARC0027Error {\n return typeof error === 'object' && 'code' in error && 'message' in error\n}\n\nexport abstract class AVMProvider extends BaseWallet {\n public avmWebClient: AVMWebProviderSDK.AVMWebClient | null = null\n protected avmWebProviderSDK: typeof AVMWebProviderSDK | null = null\n protected providerId: string\n\n constructor(params: AdapterConstructorParams & { providerId: string }) {\n super(params)\n this.providerId = params.providerId\n }\n\n protected async _initializeAVMWebProviderSDK(): Promise<typeof AVMWebProviderSDK> {\n if (!this.avmWebProviderSDK) {\n this.logger.info('Initializing @agoralabs-sh/avm-web-provider...')\n\n const module = await import('@agoralabs-sh/avm-web-provider')\n this.avmWebProviderSDK = module.default ? module.default : module\n\n if (!this.avmWebProviderSDK) {\n throw new Error(\n 'Failed to initialize, the @agoralabs-sh/avm-web-provider SDK was not provided'\n )\n }\n\n if (!this.avmWebProviderSDK.AVMWebClient) {\n throw new Error(\n 'Failed to initialize, AVMWebClient missing from @agoralabs-sh/avm-web-provider SDK'\n )\n }\n this.logger.info('@agoralabs-sh/avm-web-provider SDK initialized')\n }\n\n return this.avmWebProviderSDK\n }\n\n protected async _initializeAVMWebClient(): Promise<AVMWebProviderSDK.AVMWebClient> {\n const avmWebProviderSDK = await this._initializeAVMWebProviderSDK()\n\n if (!avmWebProviderSDK.AVMWebClient) {\n throw new Error('Failed to initialize, AVMWebClient not found')\n }\n\n if (!this.avmWebClient) {\n this.logger.info('Initializing new AVM Web Client...')\n this.avmWebClient = avmWebProviderSDK.AVMWebClient.init()\n this.logger.info('AVM Web Client initialized')\n }\n\n return this.avmWebClient\n }\n\n protected async _getGenesisHash(): Promise<string> {\n // First try to get from network config\n const network = this.activeNetworkConfig\n if (network.genesisHash) {\n return network.genesisHash\n }\n\n // Fallback to API request\n const algodClient = this.getAlgodClient()\n const version = await algodClient.versionsCheck().do()\n return algosdk.bytesToBase64(version.genesisHashB64)\n }\n\n protected _mapAVMWebProviderAccountToWalletAccounts(\n accounts: AVMWebProviderSDK.IAccount[]\n ): WalletAccount[] {\n return accounts.map(({ address, name }, idx) => ({\n name: name || `[${this.metadata.name}] Account ${idx + 1}`,\n address\n }))\n }\n\n protected processTxns(\n txnGroup: algosdk.Transaction[],\n indexesToSign?: number[]\n ): AVMWebProviderSDK.IARC0001Transaction[] {\n const txnsToSign: AVMWebProviderSDK.IARC0001Transaction[] = []\n\n txnGroup.forEach((txn, index) => {\n const isIndexMatch = !indexesToSign || indexesToSign.includes(index)\n const signer = txn.sender.toString()\n const canSignTxn = this.addresses.includes(signer)\n\n const txnString = byteArrayToBase64(txn.toByte())\n\n if (isIndexMatch && canSignTxn) {\n txnsToSign.push({ txn: txnString })\n } else {\n txnsToSign.push({ txn: txnString, signers: [] })\n }\n })\n\n return txnsToSign\n }\n\n protected processEncodedTxns(\n txnGroup: Uint8Array[],\n indexesToSign?: number[]\n ): AVMWebProviderSDK.IARC0001Transaction[] {\n const txnsToSign: AVMWebProviderSDK.IARC0001Transaction[] = []\n\n txnGroup.forEach((txnBuffer, index) => {\n const decodedObj = algosdk.msgpackRawDecode(txnBuffer)\n const isSigned = isSignedTxn(decodedObj)\n\n const txn: algosdk.Transaction = isSigned\n ? algosdk.decodeSignedTransaction(txnBuffer).txn\n : algosdk.decodeUnsignedTransaction(txnBuffer)\n\n const isIndexMatch = !indexesToSign || indexesToSign.includes(index)\n const signer = txn.sender.toString()\n const canSignTxn = !isSigned && this.addresses.includes(signer)\n\n const txnString = byteArrayToBase64(txn.toByte())\n\n if (isIndexMatch && canSignTxn) {\n txnsToSign.push({ txn: txnString })\n } else {\n txnsToSign.push({ txn: txnString, signers: [] })\n }\n })\n\n return txnsToSign\n }\n\n /**\n * Abstract methods\n * These methods must be implemented by specific wallet providers\n */\n protected abstract _enable(): Promise<AVMWebProviderSDK.IEnableResult>\n protected abstract _disable(): Promise<AVMWebProviderSDK.IDisableResult>\n protected abstract _signTransactions(\n txns: AVMWebProviderSDK.IARC0001Transaction[]\n ): Promise<AVMWebProviderSDK.ISignTransactionsResult>\n\n /**\n * Common methods\n * These methods can be overridden by specific wallet providers if needed\n */\n public async connect(): Promise<WalletAccount[]> {\n try {\n this.logger.info('Connecting...')\n const result = await this._enable()\n this.logger.info(`Successfully connected on network \"${result.genesisId}\"`)\n\n const walletAccounts = this._mapAVMWebProviderAccountToWalletAccounts(result.accounts)\n\n const walletState: WalletState = {\n accounts: walletAccounts,\n activeAccount: walletAccounts[0]\n }\n\n this.store.addWallet(walletState)\n\n this.logger.info('Connected.', walletState)\n return walletAccounts\n } catch (error: any) {\n this.logger.error(\n 'Error connecting: ',\n isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message\n )\n throw error\n }\n }\n\n public async disconnect(): Promise<void> {\n try {\n this.logger.info('Disconnecting...')\n this.onDisconnect()\n\n const result = await this._disable()\n\n this.logger.info(\n `Successfully disconnected${result.sessionIds && result.sessionIds.length ? ` sessions [${result.sessionIds.join(',')}]` : ''} on network \"${result.genesisId}\"`\n )\n } catch (error: any) {\n this.logger.error(\n 'Error disconnecting: ',\n isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message\n )\n throw error\n }\n }\n\n public async resumeSession(): Promise<void> {\n const walletState = this.store.getWalletState()\n\n if (!walletState) {\n this.logger.info('No session to resume')\n return\n }\n\n try {\n this.logger.info('Resuming session...')\n\n const result = await this._enable()\n\n if (result.accounts.length === 0) {\n throw new Error('No accounts found!')\n }\n\n const walletAccounts = this._mapAVMWebProviderAccountToWalletAccounts(result.accounts)\n const match = compareAccounts(walletAccounts, walletState.accounts)\n\n if (!match) {\n this.logger.warn('Session accounts mismatch, updating accounts', {\n prev: walletState.accounts,\n current: walletAccounts\n })\n\n this.store.setAccounts(walletAccounts)\n }\n this.logger.info('Session resumed successfully')\n } catch (error: any) {\n this.logger.error(\n 'Error resuming session: ',\n isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message\n )\n this.onDisconnect()\n throw error\n }\n }\n\n public async signTransactions<T extends algosdk.Transaction[] | Uint8Array[]>(\n txnGroup: T | T[],\n indexesToSign?: number[]\n ): Promise<(Uint8Array | null)[]> {\n try {\n this.logger.debug('Signing transactions...', { txnGroup, indexesToSign })\n let txnsToSign: AVMWebProviderSDK.IARC0001Transaction[] = []\n\n // Determine type and process transactions for signing\n if (isTransactionArray(txnGroup)) {\n const flatTxns: algosdk.Transaction[] = flattenTxnGroup(txnGroup)\n txnsToSign = this.processTxns(flatTxns, indexesToSign)\n } else {\n const flatTxns: Uint8Array[] = flattenTxnGroup(txnGroup as Uint8Array[])\n txnsToSign = this.processEncodedTxns(flatTxns, indexesToSign)\n }\n\n this.logger.debug('Sending processed transactions to wallet...', txnsToSign)\n\n // Sign transactions\n const signTxnsResult = await this._signTransactions(txnsToSign)\n this.logger.debug('Received signed transactions from wallet', signTxnsResult)\n\n // Convert base64 to Uint8Array\n const result = signTxnsResult.stxns.map((value) => {\n if (value === null) {\n return null\n }\n return base64ToByteArray(value)\n })\n\n this.logger.debug('Transactions signed successfully', result)\n return result\n } catch (error: any) {\n this.logger.error(\n 'Error signing transactions: ',\n isAVMWebProviderSDKError(error) ? `${error.message} (code: ${error.code})` : error.message\n )\n throw error\n }\n }\n}\n","export const icon = `\n<svg viewBox=\"0 0 480 480\" xmlns=\"http://www.w3.org/2000/svg\">\n <rect fill=\"#801C96\" width=\"480\" height=\"480\" />\n <path fill=\"#FFFFFF\" d=\"M393.5,223.2c0-7.3-0.6-14.6-1.6-21.6c-0.9-6.5-2.3-12.8-4-18.9c-18-64.9-77.4-112.5-148-112.5c-70.6,0-130,47.6-148,112.5c-1.7,6.2-3,12.5-4,19c-1,7.1-1.6,14.3-1.6,21.6h0v85.5h19.7v-85.5c0-7.2,0.6-14.4,1.8-21.4c14,1.1,27.6,4.3,40.5,9.5c15.9,6.4,30.3,15.6,42.6,27.3c12.3,11.7,22,25.4,28.7,40.6c6.9,15.6,10.5,32.2,10.5,49.2v81.4h0.1h19.6h0.1v-81.5c0.1-17.1,3.6-33.7,10.5-49.2c6.7-15.2,16.4-28.8,28.7-40.6c4.2-4,8.6-7.7,13.2-11.1v132.2h19.7V223.2h0c0-2.5-0.1-5-0.4-7.4c3.3-1.6,6.6-3.1,10-4.5c12.9-5.2,26.4-8.4,40.4-9.5c1.2,7,1.7,14.2,1.8,21.4v85.5h19.7L393.5,223.2L393.5,223.2z M240.1,277.3c-11.6-29.3-32.7-54.1-59.8-71c2.9-10,8.2-19.1,15.8-26.6c11.8-11.8,27.4-18.2,44-18.2s32.3,6.5,44,18.2c4.1,4.1,7.5,8.7,10.3,13.6c5.6-3.4,11.4-6.4,17.4-9.2c-14-25.2-40.9-42.3-71.8-42.3c-35.9,0-66.3,23-77.5,55.1c-15.5-7.1-32.5-11.8-50.4-13.5c1.3-4,2.7-7.9,4.3-11.8c6.7-15.9,16.4-30.3,28.7-42.6s26.6-22,42.6-28.7c16.5-7,34-10.5,52.1-10.5s35.6,3.5,52.1,10.5c15.9,6.7,30.3,16.4,42.6,28.7s22,26.6,28.7,42.6c1.6,3.9,3.1,7.8,4.3,11.8C309,189.2,260.1,226.5,240.1,277.3z\" />\n <path fill=\"#FFFFFF\" d=\"M158.1,359.8h19.7V245.5c-6.1-5.4-12.7-10-19.7-14V359.8z\" />\n</svg>\n`\n","import { AVMProvider } from './avm-provider'\nimport type { AdapterConstructorParams, WalletMetadata } from '@txnlab/use-wallet/adapter'\nimport type AVMWebProviderSDK from '@agoralabs-sh/avm-web-provider'\n\nconst PROVIDER_ID = 'f6d1c86b-4493-42fb-b88d-a62407b4cdf6'\n\nimport { icon } from './icon'\n\nconst ICON = `data:image/svg+xml;base64,${btoa(icon)}`\n\nexport class KibisisAdapter extends AVMProvider {\n constructor(params: AdapterConstructorParams) {\n super({ ...params, providerId: PROVIDER_ID })\n }\n\n static defaultMetadata: WalletMetadata = {\n name: 'Kibisis',\n icon: ICON\n }\n\n /**\n * Calls the \"enable\" method on the provider. This method will timeout after 3 minutes.\n * @returns {Promise<AVMWebProviderSDK.IEnableResult>} a promise that resolves to the result.\n * @protected\n * @throws {MethodCanceledError} if the method was cancelled by the user.\n * @throws {MethodNotSupportedError} if the method is not supported for the configured network.\n * @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).\n * @throws {NetworkNotSupportedError} if the network is not supported for the configured network.\n * @throws {UnknownError} if the response result is empty.\n */\n protected async _enable(): Promise<AVMWebProviderSDK.IEnableResult> {\n const {\n ARC0027MethodEnum,\n ARC0027MethodTimedOutError,\n ARC0027UnknownError,\n DEFAULT_REQUEST_TIMEOUT\n } = await this._initializeAVMWebProviderSDK()\n const avmWebClient = await this._initializeAVMWebClient()\n const genesisHash = await this._getGenesisHash()\n\n return new Promise<AVMWebProviderSDK.IEnableResult>((resolve, reject) => {\n const timerId = window.setTimeout(() => {\n // remove the listener\n avmWebClient.removeListener(listenerId)\n reject(\n new ARC0027MethodTimedOutError({\n method: ARC0027MethodEnum.Enable,\n message: `no response from provider \"${this.metadata.name}\"`,\n providerId: PROVIDER_ID\n })\n )\n }, DEFAULT_REQUEST_TIMEOUT)\n const listenerId = avmWebClient.onEnable(({ error, method, result }) => {\n // remove the listener, it is not needed\n avmWebClient.removeListener(listenerId)\n\n // remove the timeout\n window.clearTimeout(timerId)\n\n if (error) {\n return reject(error)\n }\n\n if (!result) {\n return reject(\n new ARC0027UnknownError({\n message: `received response, but \"${method}\" request details were empty for provider \"${this.metadata.name}\"`,\n providerId: PROVIDER_ID\n })\n )\n }\n\n return resolve(result)\n })\n\n // send the request\n avmWebClient.enable({\n genesisHash,\n providerId: PROVIDER_ID\n })\n })\n }\n\n /**\n * Calls the \"disable\" method on the provider. This method will timeout after 0.75 seconds.\n * @returns {Promise<AVMWebProviderSDK.IDisableResult>} a promise that resolves to the result.\n * @protected\n * @throws {MethodNotSupportedError} if the method is not supported for the configured network.\n * @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).\n * @throws {NetworkNotSupportedError} if the network is not supported for the configured network.\n * @throws {UnknownError} if the response result is empty.\n */\n protected async _disable(): Promise<AVMWebProviderSDK.IDisableResult> {\n const {\n ARC0027MethodEnum,\n ARC0027MethodTimedOutError,\n ARC0027UnknownError,\n LOWER_REQUEST_TIMEOUT\n } = await this._initializeAVMWebProviderSDK()\n const avmWebClient = await this._initializeAVMWebClient()\n const genesisHash = await this._getGenesisHash()\n\n return new Promise<AVMWebProviderSDK.IDisableResult>((resolve, reject) => {\n const timerId = window.setTimeout(() => {\n // remove the listener\n avmWebClient.removeListener(listenerId)\n reject(\n new ARC0027MethodTimedOutError({\n method: ARC0027MethodEnum.Disable,\n message: `no response from provider \"${this.metadata.name}\"`,\n providerId: PROVIDER_ID\n })\n )\n }, LOWER_REQUEST_TIMEOUT)\n const listenerId = avmWebClient.onDisable(({ error, method, result }) => {\n // remove the listener, it is not needed\n avmWebClient.removeListener(listenerId)\n\n // remove the timeout\n window.clearTimeout(timerId)\n\n if (error) {\n return reject(error)\n }\n\n if (!result) {\n return reject(\n new ARC0027UnknownError({\n message: `received response, but \"${method}\" request details were empty for provider \"${this.metadata.name}\"`,\n providerId: PROVIDER_ID\n })\n )\n }\n\n this.logger.debug('Disable successful', { result })\n return resolve(result)\n })\n\n this.logger.debug('Sending disable request...', { genesisHash })\n avmWebClient.disable({\n genesisHash,\n providerId: PROVIDER_ID\n })\n })\n }\n\n /**\n * Calls the \"signTransactions\" method to sign the supplied ARC-0001 transactions. This method\n * will timeout after 3 minutes.\n * @returns {Promise<AVMWebProviderSDK.ISignTransactionsResult>} a promise that resolves to the result.\n * @protected\n * @throws {InvalidInputError} if computed group ID for the txns does not match the assigned group ID.\n * @throws {InvalidGroupIdError} if the unsigned txns is malformed or not conforming to ARC-0001.\n * @throws {MethodCanceledError} if the method was cancelled by the user.\n * @throws {MethodNotSupportedError} if the method is not supported for the configured network.\n * @throws {MethodTimedOutError} if the method timed out by lack of response (>= 3 minutes).\n * @throws {NetworkNotSupportedError} if the network is not supported for the configured network.\n * @throws {UnauthorizedSignerError} if a signer in the request is not authorized by the provider.\n * @throws {UnknownError} if the response result is empty.\n */\n protected async _signTransactions(\n txns: AVMWebProviderSDK.IARC0001Transaction[]\n ): Promise<AVMWebProviderSDK.ISignTransactionsResult> {\n const {\n ARC0027MethodEnum,\n ARC0027MethodTimedOutError,\n ARC0027UnknownError,\n DEFAULT_REQUEST_TIMEOUT\n } = await this._initializeAVMWebProviderSDK()\n const avmWebClient = await this._initializeAVMWebClient()\n\n return new Promise<AVMWebProviderSDK.ISignTransactionsResult>((resolve, reject) => {\n const timerId = window.setTimeout(() => {\n // remove the listener\n avmWebClient.removeListener(listenerId)\n reject(\n new ARC0027MethodTimedOutError({\n method: ARC0027MethodEnum.SignTransactions,\n message: `no response from provider \"${this.metadata.name}\"`,\n providerId: PROVIDER_ID\n })\n )\n }, DEFAULT_REQUEST_TIMEOUT)\n const listenerId = avmWebClient.onSignTransactions(({ error, method, result }) => {\n // remove the listener, it is not needed\n avmWebClient.removeListener(listenerId)\n\n // remove the timeout\n window.clearTimeout(timerId)\n\n if (error) {\n return reject(error)\n }\n\n if (!result) {\n return reject(\n new ARC0027UnknownError({\n message: `received response, but \"${method}\" request details were empty for provider \"${this.metadata.name}\"`,\n providerId: PROVIDER_ID\n })\n )\n }\n\n this.logger.debug('Sign transactions successful', { result })\n return resolve(result)\n })\n\n this.logger.debug('Sending sign transactions request...', { txns })\n avmWebClient.signTransactions({\n txns,\n providerId: PROVIDER_ID\n })\n })\n }\n}\n","import { KibisisAdapter } from './adapter'\nimport type { WalletAdapterConfig } from '@txnlab/use-wallet'\n\nexport const WALLET_ID = 'kibisis' as const\n\nexport function kibisis(): WalletAdapterConfig {\n return {\n id: WALLET_ID,\n metadata: KibisisAdapter.defaultMetadata,\n Adapter: KibisisAdapter as unknown as WalletAdapterConfig['Adapter']\n }\n}\n\nexport { KibisisAdapter }\n"],"mappings":";;;AAeA,SAAgB,yBAAyB,OAAyD;AAChG,QAAO,OAAO,UAAU,YAAY,UAAU,SAAS,aAAa;;AAGtE,IAAsB,cAAtB,cAA0C,WAAW;CACnD,eAA6D;CAC7D,oBAA+D;CAC/D;CAEA,YAAY,QAA2D;AACrE,QAAM,OAAO;AACb,OAAK,aAAa,OAAO;;CAG3B,MAAgB,+BAAkE;AAChF,MAAI,CAAC,KAAK,mBAAmB;AAC3B,QAAK,OAAO,KAAK,iDAAiD;GAElE,MAAM,SAAS,MAAM,OAAO;AAC5B,QAAK,oBAAoB,OAAO,UAAU,OAAO,UAAU;AAE3D,OAAI,CAAC,KAAK,kBACR,OAAM,IAAI,MACR,gFACD;AAGH,OAAI,CAAC,KAAK,kBAAkB,aAC1B,OAAM,IAAI,MACR,qFACD;AAEH,QAAK,OAAO,KAAK,iDAAiD;;AAGpE,SAAO,KAAK;;CAGd,MAAgB,0BAAmE;EACjF,MAAM,oBAAoB,MAAM,KAAK,8BAA8B;AAEnE,MAAI,CAAC,kBAAkB,aACrB,OAAM,IAAI,MAAM,+CAA+C;AAGjE,MAAI,CAAC,KAAK,cAAc;AACtB,QAAK,OAAO,KAAK,qCAAqC;AACtD,QAAK,eAAe,kBAAkB,aAAa,MAAM;AACzD,QAAK,OAAO,KAAK,6BAA6B;;AAGhD,SAAO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E,MAAM,CAAC;AACnE,gBAAa,iBAAiB;IAC5B;IACA,YAAY;IACb,CAAC;IACF;;;;;ACjNN,MAAa,YAAY;AAEzB,SAAgB,UAA+B;AAC7C,QAAO;EACL,IAAI;EACJ,UAAU,eAAe;EACzB,SAAS;EACV"}
|
package/package.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@txnlab/use-wallet-kibisis",
|
|
3
|
+
"version": "5.0.0-rc.1",
|
|
4
|
+
"publishConfig": {
|
|
5
|
+
"access": "public",
|
|
6
|
+
"provenance": true
|
|
7
|
+
},
|
|
8
|
+
"description": "Kibisis Wallet adapter for @txnlab/use-wallet",
|
|
9
|
+
"author": "Doug Richar <drichar@gmail.com>",
|
|
10
|
+
"license": "MIT",
|
|
11
|
+
"repository": {
|
|
12
|
+
"type": "git",
|
|
13
|
+
"url": "git+https://github.com/txnlab/use-wallet.git",
|
|
14
|
+
"directory": "packages/wallets/kibisis"
|
|
15
|
+
},
|
|
16
|
+
"type": "module",
|
|
17
|
+
"main": "./dist/index.js",
|
|
18
|
+
"types": "./dist/index.d.ts",
|
|
19
|
+
"exports": {
|
|
20
|
+
".": {
|
|
21
|
+
"types": "./dist/index.d.ts",
|
|
22
|
+
"default": "./dist/index.js"
|
|
23
|
+
}
|
|
24
|
+
},
|
|
25
|
+
"files": [
|
|
26
|
+
"dist"
|
|
27
|
+
],
|
|
28
|
+
"peerDependencies": {
|
|
29
|
+
"@txnlab/use-wallet": "^5.0.0",
|
|
30
|
+
"algosdk": "^3.0.0"
|
|
31
|
+
},
|
|
32
|
+
"dependencies": {
|
|
33
|
+
"@agoralabs-sh/avm-web-provider": "1.7.0"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@txnlab/use-wallet": "5.0.0-rc.1",
|
|
37
|
+
"algosdk": "3.5.2",
|
|
38
|
+
"tsdown": "0.21.0",
|
|
39
|
+
"typescript": "5.9.3"
|
|
40
|
+
},
|
|
41
|
+
"scripts": {
|
|
42
|
+
"build": "tsdown",
|
|
43
|
+
"start": "tsdown --watch",
|
|
44
|
+
"test": "vitest run",
|
|
45
|
+
"test:watch": "vitest --watch",
|
|
46
|
+
"lint": "eslint \"src/**/*.{js,ts}\"",
|
|
47
|
+
"typecheck": "tsc --noEmit"
|
|
48
|
+
}
|
|
49
|
+
}
|