@canton-network/dapp-sdk 1.9.0 → 1.10.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/dapp-api/rpc-gen/typings.d.ts +30 -0
- package/dist/dapp-api/rpc-gen/typings.d.ts.map +1 -1
- package/dist/index.cjs +25 -16
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +26 -17
- package/dist/index.js.map +1 -1
- package/dist/sdk-controller.d.ts.map +1 -1
- package/dist/sdk.d.ts +8 -4
- package/dist/sdk.d.ts.map +1 -1
- package/package.json +12 -12
package/dist/index.js
CHANGED
|
@@ -3,12 +3,12 @@ import { CANTON_ANNOUNCE_PROVIDER_EVENT, CANTON_REQUEST_PROVIDER_EVENT, Discover
|
|
|
3
3
|
import { notifyWalletPickerConnected, notifyWalletPickerError, pickWallet, popup, waitForWalletPickerRetrySelection } from "@canton-network/core-wallet-ui-components";
|
|
4
4
|
import { DiscoveryClient, DiscoveryClient as DiscoveryClient$1, DiscoveryError, EventEmitter, NotConnectedError, SessionExpiredError, TimeoutError, UserRejectedError, WalletNotFoundError, WalletNotInstalledError } from "@canton-network/core-wallet-discovery";
|
|
5
5
|
import { WindowTransport } from "@canton-network/core-rpc-transport";
|
|
6
|
-
import { errorCodes, providerErrors, rpcErrors, toJsonRpcError } from "@canton-network/core-rpc-errors";
|
|
6
|
+
import { JsonRpcError, errorCodes, isCip103ErrorCode, providerErrors, rpcErrors, toJsonRpcError } from "@canton-network/core-rpc-errors";
|
|
7
7
|
import SignClient from "@walletconnect/sign-client";
|
|
8
8
|
import * as dappAPI from "@canton-network/core-wallet-dapp-rpc-client";
|
|
9
9
|
// src/version.ts
|
|
10
10
|
/** Published version of `@canton-network/dapp-sdk`. */
|
|
11
|
-
const SDK_VERSION = "1.
|
|
11
|
+
const SDK_VERSION = "1.10.0";
|
|
12
12
|
const DAPP_SDK_BUILD = Object.freeze({
|
|
13
13
|
name: "@canton-network/dapp-sdk",
|
|
14
14
|
version: SDK_VERSION
|
|
@@ -84,7 +84,7 @@ const composeSIWXMessage = (params) => {
|
|
|
84
84
|
params.resources?.length && params.resources.reduce((acc, resource) => `${acc}\n- ${resource}`, "Resources:")
|
|
85
85
|
].filter((line) => typeof line === "string").join("\n").trim();
|
|
86
86
|
};
|
|
87
|
-
// \0@oxc-project+runtime@0.
|
|
87
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/typeof.js
|
|
88
88
|
function _typeof(o) {
|
|
89
89
|
"@babel/helpers - typeof";
|
|
90
90
|
return _typeof = "function" == typeof Symbol && "symbol" == typeof Symbol.iterator ? function(o) {
|
|
@@ -93,23 +93,23 @@ function _typeof(o) {
|
|
|
93
93
|
return o && "function" == typeof Symbol && o.constructor === Symbol && o !== Symbol.prototype ? "symbol" : typeof o;
|
|
94
94
|
}, _typeof(o);
|
|
95
95
|
}
|
|
96
|
-
// \0@oxc-project+runtime@0.
|
|
97
|
-
function toPrimitive(t,
|
|
96
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPrimitive.js
|
|
97
|
+
function toPrimitive(t, e) {
|
|
98
98
|
if ("object" != _typeof(t) || !t) return t;
|
|
99
|
-
var
|
|
100
|
-
if (void 0 !==
|
|
101
|
-
var i =
|
|
99
|
+
var r;
|
|
100
|
+
if ("undefined" != typeof Symbol && void 0 !== (r = t[Symbol.toPrimitive])) {
|
|
101
|
+
var i = r.call(t, e || "default");
|
|
102
102
|
if ("object" != _typeof(i)) return i;
|
|
103
103
|
throw new TypeError("@@toPrimitive must return a primitive value.");
|
|
104
104
|
}
|
|
105
|
-
return ("string" ===
|
|
105
|
+
return ("string" === e ? String : Number)(t);
|
|
106
106
|
}
|
|
107
|
-
// \0@oxc-project+runtime@0.
|
|
107
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/toPropertyKey.js
|
|
108
108
|
function toPropertyKey(t) {
|
|
109
109
|
var i = toPrimitive(t, "string");
|
|
110
110
|
return "symbol" == _typeof(i) ? i : i + "";
|
|
111
111
|
}
|
|
112
|
-
// \0@oxc-project+runtime@0.
|
|
112
|
+
// \0@oxc-project+runtime@0.157.0/helpers/esm/defineProperty.js
|
|
113
113
|
function _defineProperty(e, r, t) {
|
|
114
114
|
return (r = toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
|
|
115
115
|
value: t,
|
|
@@ -321,6 +321,11 @@ const withTimeout = (reject, details, timeoutMs = 3e5) => setTimeout(() => {
|
|
|
321
321
|
console.warn(`SDK: ${details}`);
|
|
322
322
|
reject(rpcErrors.resourceUnavailable(details));
|
|
323
323
|
}, timeoutMs);
|
|
324
|
+
const toFailureError = (details, error) => {
|
|
325
|
+
if (!error) return rpcErrors.transactionRejected(`${details}.`);
|
|
326
|
+
const message = `${details}: ${error.message}`;
|
|
327
|
+
return isCip103ErrorCode(error.code) ? new JsonRpcError(error.code, message, error.data) : rpcErrors.transactionRejected(message);
|
|
328
|
+
};
|
|
324
329
|
const dappSDKController = (provider) => buildController({
|
|
325
330
|
connect: async () => {
|
|
326
331
|
const response = await provider.request({ method: "connect" });
|
|
@@ -370,7 +375,7 @@ const dappSDKController = (provider) => buildController({
|
|
|
370
375
|
if (event.status === "failed") {
|
|
371
376
|
provider.removeListener("txChanged", listener);
|
|
372
377
|
clearTimeout(timeout);
|
|
373
|
-
reject(
|
|
378
|
+
reject(toFailureError(`Transaction with commandId ${event.commandId} failed to execute`, event.error));
|
|
374
379
|
}
|
|
375
380
|
if (event.status === "executed") {
|
|
376
381
|
provider.removeListener("txChanged", listener);
|
|
@@ -408,7 +413,7 @@ const dappSDKController = (provider) => buildController({
|
|
|
408
413
|
provider.removeListener("messageSignature", listener);
|
|
409
414
|
clearTimeout(timeout);
|
|
410
415
|
if (event.status === "failed") {
|
|
411
|
-
reject(
|
|
416
|
+
reject(toFailureError(`Message signing failed for messageId ${event.messageId}`, event.error));
|
|
412
417
|
return;
|
|
413
418
|
}
|
|
414
419
|
resolve({ signature: event.signature });
|
|
@@ -1161,15 +1166,19 @@ var DappSDK = class {
|
|
|
1161
1166
|
return this.requireClient().prepareExecute(params);
|
|
1162
1167
|
}
|
|
1163
1168
|
/**
|
|
1164
|
-
* @throws `JsonRpcError` with
|
|
1165
|
-
*
|
|
1169
|
+
* @throws `JsonRpcError` with the CIP-103 code reported by the wallet if the transaction
|
|
1170
|
+
* fails, e.g. `userRejectedRequest` if the user declines it or `transactionRejected` if it
|
|
1171
|
+
* is rejected (also used when the wallet reports no code), and `resourceUnavailable` if no
|
|
1172
|
+
* outcome arrives in time.
|
|
1166
1173
|
*/
|
|
1167
1174
|
async prepareExecuteAndWait(params) {
|
|
1168
1175
|
return this.requireClient().prepareExecuteAndWait(params);
|
|
1169
1176
|
}
|
|
1170
1177
|
/**
|
|
1171
|
-
* @throws `JsonRpcError` with
|
|
1172
|
-
*
|
|
1178
|
+
* @throws `JsonRpcError` with the CIP-103 code reported by the wallet if signing fails,
|
|
1179
|
+
* e.g. `userRejectedRequest` if the user declines it or `transactionRejected` if it is
|
|
1180
|
+
* rejected (also used when the wallet reports no code), and `resourceUnavailable` if no
|
|
1181
|
+
* signature arrives in time.
|
|
1173
1182
|
*/
|
|
1174
1183
|
async signMessage(params) {
|
|
1175
1184
|
return this.requireClient().signMessage(params);
|