@fairmint/canton-node-sdk 0.0.290 → 0.0.292

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.
Files changed (57) hide show
  1. package/README.md +51 -0
  2. package/build/src/wallets/abort.d.ts +13 -0
  3. package/build/src/wallets/abort.d.ts.map +1 -1
  4. package/build/src/wallets/abort.js +66 -0
  5. package/build/src/wallets/abort.js.map +1 -1
  6. package/build/src/wallets/connector.d.ts +181 -0
  7. package/build/src/wallets/connector.d.ts.map +1 -0
  8. package/build/src/wallets/connector.js +686 -0
  9. package/build/src/wallets/connector.js.map +1 -0
  10. package/build/src/wallets/da-utilities/client.d.ts +10 -0
  11. package/build/src/wallets/da-utilities/client.d.ts.map +1 -1
  12. package/build/src/wallets/da-utilities/client.js +41 -13
  13. package/build/src/wallets/da-utilities/client.js.map +1 -1
  14. package/build/src/wallets/errors.d.ts +40 -5
  15. package/build/src/wallets/errors.d.ts.map +1 -1
  16. package/build/src/wallets/errors.js +79 -2
  17. package/build/src/wallets/errors.js.map +1 -1
  18. package/build/src/wallets/format.d.ts +54 -0
  19. package/build/src/wallets/format.d.ts.map +1 -0
  20. package/build/src/wallets/format.js +57 -0
  21. package/build/src/wallets/format.js.map +1 -0
  22. package/build/src/wallets/index.d.ts +15 -4
  23. package/build/src/wallets/index.d.ts.map +1 -1
  24. package/build/src/wallets/index.js +34 -1
  25. package/build/src/wallets/index.js.map +1 -1
  26. package/build/src/wallets/latch.d.ts +70 -0
  27. package/build/src/wallets/latch.d.ts.map +1 -0
  28. package/build/src/wallets/latch.js +100 -0
  29. package/build/src/wallets/latch.js.map +1 -0
  30. package/build/src/wallets/loop.d.ts +36 -0
  31. package/build/src/wallets/loop.d.ts.map +1 -0
  32. package/build/src/wallets/loop.js +59 -0
  33. package/build/src/wallets/loop.js.map +1 -0
  34. package/build/src/wallets/options.d.ts +76 -0
  35. package/build/src/wallets/options.d.ts.map +1 -0
  36. package/build/src/wallets/options.js +21 -0
  37. package/build/src/wallets/options.js.map +1 -0
  38. package/build/src/wallets/ownership.d.ts.map +1 -1
  39. package/build/src/wallets/ownership.js +2 -5
  40. package/build/src/wallets/ownership.js.map +1 -1
  41. package/build/src/wallets/sign-message.d.ts +43 -0
  42. package/build/src/wallets/sign-message.d.ts.map +1 -0
  43. package/build/src/wallets/sign-message.js +56 -0
  44. package/build/src/wallets/sign-message.js.map +1 -0
  45. package/build/src/wallets/storage.d.ts +17 -0
  46. package/build/src/wallets/storage.d.ts.map +1 -0
  47. package/build/src/wallets/storage.js +55 -0
  48. package/build/src/wallets/storage.js.map +1 -0
  49. package/build/src/wallets/store.d.ts +74 -4
  50. package/build/src/wallets/store.d.ts.map +1 -1
  51. package/build/src/wallets/store.js +174 -33
  52. package/build/src/wallets/store.js.map +1 -1
  53. package/build/src/wallets/tokens.d.ts +48 -11
  54. package/build/src/wallets/tokens.d.ts.map +1 -1
  55. package/build/src/wallets/tokens.js +35 -14
  56. package/build/src/wallets/tokens.js.map +1 -1
  57. package/package.json +1 -1
@@ -26,20 +26,31 @@
26
26
  * (`createWalletOwnershipChallenger`, `verifyWalletOwnership`) is Node-only and exported from the package root.
27
27
  * - The errors, their guards (`isWalletError`, `isWalletSubmitError`, …: they match errors of any copy of this module,
28
28
  * where `instanceof` does not), their user-facing descriptions (`describeWalletError`), and the data types.
29
+ * - Display helpers that return codes, not sentences: `selectWalletToken`, `formatTokenAmount`, `formatOfferExpiry`,
30
+ * `describePreapprovalScope`, `shortCantonId`, `validateSignMessage` (and `readSignature` for a `signMessage`
31
+ * answer); `actionState` says why an action is disabled.
29
32
  * - Cancellation: every call that reads, fetches or acts takes an optional `signal` (`WalletCallOptions`):
30
33
  * `WalletStore.act`, `Cip103Session.connect` and `restore`, `DiscoveredWallet.load` included. `WalletStore.dispose()`
31
34
  * cancels the store's own work in flight the same way.
32
35
  */
33
36
  export { createCip103Session, type Cip103Session, type Cip103SessionOptions, type Cip103SessionState, type ConnectedWallet, } from './session';
34
- export { canAct, createWalletStore, walletActionKey, type ActionOutcome, type ActionResultOf, type UnknownOutcome, type WalletAction, type WalletActionResults, type WalletNotice, type WalletStore, type WalletStoreOptions, type WalletView, } from './store';
37
+ export { createWalletConnector, DEFAULT_RESTORE_TIMEOUT_MS, type WalletConnection, type WalletConnectResult, type WalletConnector, type WalletConnectorError, type WalletConnectorInput, type WalletConnectorSnapshot, type WalletConnectorStatus, type WalletOptionState, } from './connector';
38
+ export { createWriteLatch, type WriteLatch, type WriteLatchHolder, type WriteLatchState, type WriteRunContext, type WriteRunOutcome, } from './latch';
39
+ export { loopWalletOption, type LoopSdkLike, type LoopWalletOption, type LoopWalletOptionInput } from './loop';
40
+ export { extensionWalletOptions, type LiveWalletOption, type LoadedWalletOption, type WalletAvailability, type WalletOption, type WalletOptionInfo, } from './options';
41
+ export type { StorageLike } from './storage';
42
+ export { actionState, canAct, createWalletStore, walletActionKey, type ActionOutcome, type ActionResultOf, type UnknownOutcome, type WalletAction, type WalletActionResults, type WalletNotice, type WalletStore, type WalletActionBlocker, type WalletBusyReason, type WalletStoreOptions, type WalletView, } from './store';
35
43
  export { createWallet, type BurnRequestOptions, type BurnRequestResult, type TransferOffers, type TransferPlan, type TransferPreapprovalOptions, type TransferRequest, type TransferResult, type Wallet, type WalletCallOptions, type WalletOptions, type WalletState, type WithdrawExpiredResult, type WithdrawnOffer, type ReleasedLock, type ReclaimLockedTokensResult, } from './wallet';
36
44
  export type { Cip103Connection, Cip103EventListener, Cip103Provider, Cip103Request } from './cip103';
37
45
  export { discoverCip103Wallets, INJECTED_WALLET_ID, type Cip103DiscoveryHost, type DiscoverCip103WalletsOptions, type DiscoveredWallet, } from './discovery';
38
46
  export { buildWalletOwnershipMessage, proveWalletOwnership, requestWalletOwnershipVerdict, type ProveWalletOwnershipOptions, type RequestWalletOwnershipVerdictOptions, type WalletOwnershipChallenge, type WalletOwnershipChallengeFailure, type WalletOwnershipChallengeResponse, type WalletOwnershipFailure, type WalletOwnershipMessageFields, type WalletOwnershipProof, type WalletOwnershipVerdict, } from './ownership';
39
- export type { DaNetwork, DaRegistryOptions, FetchLike, TransferKind } from './da-utilities/client';
40
- export { describeWalletError, isRegistryApiError, isRegistryResponseError, isWalletCancellation, isWalletError, isWalletReadError, isWalletSignError, isWalletSubmitError, RegistryApiError, RegistryResponseError, WalletError, WalletReadError, WalletSignError, WalletSubmitError, type WalletErrorCode, type WalletErrorDescription, type WalletSignErrorReason, type WalletSubmitCategory, type WalletSubmitErrorDetails, type WalletSubmitOutcome, } from './errors';
47
+ export { DA_REGISTRY_REQUEST_TIMEOUT_MS, type DaNetwork, type DaRegistryOptions, type FetchLike, type TransferKind, } from './da-utilities/client';
48
+ export { describeWalletError, isRegistryApiError, isRegistryResponseError, isWalletCancellation, isWalletError, isWalletOptionError, isWalletReadError, isWalletSignError, isWalletSubmitError, RegistryApiError, RegistryResponseError, WalletError, WalletOptionError, WalletReadError, WalletSignError, WalletSubmitError, type WalletErrorCode, type WalletErrorDescription, type WalletOptionErrorCode, type WalletSignErrorReason, type WalletSubmitCategory, type WalletSubmitErrorDetails, type WalletSubmitOutcome, } from './errors';
41
49
  export { coveringPreapproval, type BurnRequest, type MintOffer, type PreapprovalScope, type TransferOffer, type TransferOfferRegistry, type TransferPreapproval, } from './contracts';
42
- export { isTransferOfferExpired, expiredUnclaimedLocks, walletTokens, type TokenCapabilities, type WalletToken, type WalletTokensInput, } from './tokens';
50
+ export { isTransferOfferExpired, expiredUnclaimedLocks, selectWalletToken, walletTokens, type TokenCapabilities, type WalletToken, type WalletTokenOffer, type WalletTokensInput, type WalletTokensOptions, } from './tokens';
51
+ export { describePreapprovalScope, formatOfferExpiry, formatTokenAmount, OFFER_EXPIRY_SOON_MS, shortCantonId, type OfferExpiry, type PreapprovalScopeDescription, } from './format';
52
+ export { readSignature, SIGN_MESSAGE_MAX_BYTES, SIGN_MESSAGE_MIN_BYTES, validateSignMessage, type SignMessageProblem, type ValidateSignMessageOptions, } from './sign-message';
53
+ export { MAX_TIMER_MS, withTimeout } from './abort';
43
54
  export { isCantonCoin, type Holding, type HoldingSource, type InstrumentBalance, type InstrumentMetadata, } from './holdings';
44
55
  export { AMULET_INSTRUMENT_ID, AMULET_REGISTRY_BASE_URLS, AMULET_TEMPLATES, CANTON_COIN_METADATA, } from './amulet/constants';
45
56
  export type { CantonCoinOptions } from './amulet/registry';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,OAAO,EACL,mBAAmB,EACnB,KAAK,aAAa,EAClB,KAAK,oBAAoB,EACzB,KAAK,kBAAkB,EACvB,KAAK,eAAe,GACrB,MAAM,WAAW,CAAC;AACnB,OAAO,EACL,MAAM,EACN,iBAAiB,EACjB,eAAe,EACf,KAAK,aAAa,EAClB,KAAK,cAAc,EACnB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,mBAAmB,EACxB,KAAK,YAAY,EACjB,KAAK,WAAW,EAChB,KAAK,kBAAkB,EACvB,KAAK,UAAU,GAChB,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,YAAY,EACZ,KAAK,kBAAkB,EACvB,KAAK,iBAAiB,EACtB,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,0BAA0B,EAC/B,KAAK,eAAe,EACpB,KAAK,cAAc,EACnB,KAAK,MAAM,EACX,KAAK,iBAAiB,EACtB,KAAK,aAAa,EAClB,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAC1B,KAAK,cAAc,EACnB,KAAK,YAAY,EACjB,KAAK,yBAAyB,GAC/B,MAAM,UAAU,CAAC;AAClB,YAAY,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACrG,OAAO,EACL,qBAAqB,EACrB,kBAAkB,EAClB,KAAK,mBAAmB,EACxB,KAAK,4BAA4B,EACjC,K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Y,CAAC;AACpB,OAAO,EACL,oBAAoB,EACpB,yBAAyB,EACzB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,oBAAoB,CAAC;AAC5B,YAAY,EAAE,iBAAiB,EAAE,MAAM,mBAAmB,CAAC;AAC3D,OAAO,EACL,uBAAuB,EACvB,eAAe,EACf,KAAK,WAAW,EAChB,KAAK,eAAe,EACpB,KAAK,mBAAmB,GACzB,MAAM,gBAAgB,CAAC;AACxB,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAC1D,OAAO,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,WAAW,CAAC"}
@@ -1,6 +1,7 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.parseDecimalUnits = exports.formatDecimalUnits = exports.readHoldingView = exports.HOLDING_V1_INTERFACE_ID = exports.CANTON_COIN_METADATA = exports.AMULET_TEMPLATES = exports.AMULET_REGISTRY_BASE_URLS = exports.AMULET_INSTRUMENT_ID = exports.isCantonCoin = exports.walletTokens = exports.expiredUnclaimedLocks = exports.isTransferOfferExpired = exports.coveringPreapproval = exports.WalletSubmitError = exports.WalletSignError = exports.WalletReadError = exports.WalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.isWalletSubmitError = exports.isWalletSignError = exports.isWalletReadError = exports.isWalletError = exports.isWalletCancellation = exports.isRegistryResponseError = exports.isRegistryApiError = exports.describeWalletError = exports.requestWalletOwnershipVerdict = exports.proveWalletOwnership = exports.buildWalletOwnershipMessage = exports.INJECTED_WALLET_ID = exports.discoverCip103Wallets = exports.createWallet = exports.walletActionKey = exports.createWalletStore = exports.canAct = exports.createCip103Session = void 0;
3
+ exports.isCantonCoin = exports.withTimeout = exports.MAX_TIMER_MS = exports.validateSignMessage = exports.SIGN_MESSAGE_MIN_BYTES = exports.SIGN_MESSAGE_MAX_BYTES = exports.readSignature = exports.shortCantonId = exports.OFFER_EXPIRY_SOON_MS = exports.formatTokenAmount = exports.formatOfferExpiry = exports.describePreapprovalScope = exports.walletTokens = exports.selectWalletToken = exports.expiredUnclaimedLocks = exports.isTransferOfferExpired = exports.coveringPreapproval = exports.WalletSubmitError = exports.WalletSignError = exports.WalletReadError = exports.WalletOptionError = exports.WalletError = exports.RegistryResponseError = exports.RegistryApiError = exports.isWalletSubmitError = exports.isWalletSignError = exports.isWalletReadError = exports.isWalletOptionError = exports.isWalletError = exports.isWalletCancellation = exports.isRegistryResponseError = exports.isRegistryApiError = exports.describeWalletError = exports.DA_REGISTRY_REQUEST_TIMEOUT_MS = exports.requestWalletOwnershipVerdict = exports.proveWalletOwnership = exports.buildWalletOwnershipMessage = exports.INJECTED_WALLET_ID = exports.discoverCip103Wallets = exports.createWallet = exports.walletActionKey = exports.createWalletStore = exports.canAct = exports.actionState = exports.extensionWalletOptions = exports.loopWalletOption = exports.createWriteLatch = exports.DEFAULT_RESTORE_TIMEOUT_MS = exports.createWalletConnector = exports.createCip103Session = void 0;
4
+ exports.parseDecimalUnits = exports.formatDecimalUnits = exports.readHoldingView = exports.HOLDING_V1_INTERFACE_ID = exports.CANTON_COIN_METADATA = exports.AMULET_TEMPLATES = exports.AMULET_REGISTRY_BASE_URLS = exports.AMULET_INSTRUMENT_ID = void 0;
4
5
  /**
5
6
  * Browser-safe DA Utility Registry holder actions through any CIP-0103 (Canton dApp API) wallet provider. In a browser
6
7
  * bundle import `@fairmint/canton-node-sdk/wallets`, which loads none of the SDK's Node dependencies (the deep path
@@ -29,13 +30,26 @@ exports.parseDecimalUnits = exports.formatDecimalUnits = exports.readHoldingView
29
30
  * (`createWalletOwnershipChallenger`, `verifyWalletOwnership`) is Node-only and exported from the package root.
30
31
  * - The errors, their guards (`isWalletError`, `isWalletSubmitError`, …: they match errors of any copy of this module,
31
32
  * where `instanceof` does not), their user-facing descriptions (`describeWalletError`), and the data types.
33
+ * - Display helpers that return codes, not sentences: `selectWalletToken`, `formatTokenAmount`, `formatOfferExpiry`,
34
+ * `describePreapprovalScope`, `shortCantonId`, `validateSignMessage` (and `readSignature` for a `signMessage`
35
+ * answer); `actionState` says why an action is disabled.
32
36
  * - Cancellation: every call that reads, fetches or acts takes an optional `signal` (`WalletCallOptions`):
33
37
  * `WalletStore.act`, `Cip103Session.connect` and `restore`, `DiscoveredWallet.load` included. `WalletStore.dispose()`
34
38
  * cancels the store's own work in flight the same way.
35
39
  */
36
40
  var session_1 = require("./session");
37
41
  Object.defineProperty(exports, "createCip103Session", { enumerable: true, get: function () { return session_1.createCip103Session; } });
42
+ var connector_1 = require("./connector");
43
+ Object.defineProperty(exports, "createWalletConnector", { enumerable: true, get: function () { return connector_1.createWalletConnector; } });
44
+ Object.defineProperty(exports, "DEFAULT_RESTORE_TIMEOUT_MS", { enumerable: true, get: function () { return connector_1.DEFAULT_RESTORE_TIMEOUT_MS; } });
45
+ var latch_1 = require("./latch");
46
+ Object.defineProperty(exports, "createWriteLatch", { enumerable: true, get: function () { return latch_1.createWriteLatch; } });
47
+ var loop_1 = require("./loop");
48
+ Object.defineProperty(exports, "loopWalletOption", { enumerable: true, get: function () { return loop_1.loopWalletOption; } });
49
+ var options_1 = require("./options");
50
+ Object.defineProperty(exports, "extensionWalletOptions", { enumerable: true, get: function () { return options_1.extensionWalletOptions; } });
38
51
  var store_1 = require("./store");
52
+ Object.defineProperty(exports, "actionState", { enumerable: true, get: function () { return store_1.actionState; } });
39
53
  Object.defineProperty(exports, "canAct", { enumerable: true, get: function () { return store_1.canAct; } });
40
54
  Object.defineProperty(exports, "createWalletStore", { enumerable: true, get: function () { return store_1.createWalletStore; } });
41
55
  Object.defineProperty(exports, "walletActionKey", { enumerable: true, get: function () { return store_1.walletActionKey; } });
@@ -48,18 +62,22 @@ var ownership_1 = require("./ownership");
48
62
  Object.defineProperty(exports, "buildWalletOwnershipMessage", { enumerable: true, get: function () { return ownership_1.buildWalletOwnershipMessage; } });
49
63
  Object.defineProperty(exports, "proveWalletOwnership", { enumerable: true, get: function () { return ownership_1.proveWalletOwnership; } });
50
64
  Object.defineProperty(exports, "requestWalletOwnershipVerdict", { enumerable: true, get: function () { return ownership_1.requestWalletOwnershipVerdict; } });
65
+ var client_1 = require("./da-utilities/client");
66
+ Object.defineProperty(exports, "DA_REGISTRY_REQUEST_TIMEOUT_MS", { enumerable: true, get: function () { return client_1.DA_REGISTRY_REQUEST_TIMEOUT_MS; } });
51
67
  var errors_1 = require("./errors");
52
68
  Object.defineProperty(exports, "describeWalletError", { enumerable: true, get: function () { return errors_1.describeWalletError; } });
53
69
  Object.defineProperty(exports, "isRegistryApiError", { enumerable: true, get: function () { return errors_1.isRegistryApiError; } });
54
70
  Object.defineProperty(exports, "isRegistryResponseError", { enumerable: true, get: function () { return errors_1.isRegistryResponseError; } });
55
71
  Object.defineProperty(exports, "isWalletCancellation", { enumerable: true, get: function () { return errors_1.isWalletCancellation; } });
56
72
  Object.defineProperty(exports, "isWalletError", { enumerable: true, get: function () { return errors_1.isWalletError; } });
73
+ Object.defineProperty(exports, "isWalletOptionError", { enumerable: true, get: function () { return errors_1.isWalletOptionError; } });
57
74
  Object.defineProperty(exports, "isWalletReadError", { enumerable: true, get: function () { return errors_1.isWalletReadError; } });
58
75
  Object.defineProperty(exports, "isWalletSignError", { enumerable: true, get: function () { return errors_1.isWalletSignError; } });
59
76
  Object.defineProperty(exports, "isWalletSubmitError", { enumerable: true, get: function () { return errors_1.isWalletSubmitError; } });
60
77
  Object.defineProperty(exports, "RegistryApiError", { enumerable: true, get: function () { return errors_1.RegistryApiError; } });
61
78
  Object.defineProperty(exports, "RegistryResponseError", { enumerable: true, get: function () { return errors_1.RegistryResponseError; } });
62
79
  Object.defineProperty(exports, "WalletError", { enumerable: true, get: function () { return errors_1.WalletError; } });
80
+ Object.defineProperty(exports, "WalletOptionError", { enumerable: true, get: function () { return errors_1.WalletOptionError; } });
63
81
  Object.defineProperty(exports, "WalletReadError", { enumerable: true, get: function () { return errors_1.WalletReadError; } });
64
82
  Object.defineProperty(exports, "WalletSignError", { enumerable: true, get: function () { return errors_1.WalletSignError; } });
65
83
  Object.defineProperty(exports, "WalletSubmitError", { enumerable: true, get: function () { return errors_1.WalletSubmitError; } });
@@ -68,7 +86,22 @@ Object.defineProperty(exports, "coveringPreapproval", { enumerable: true, get: f
68
86
  var tokens_1 = require("./tokens");
69
87
  Object.defineProperty(exports, "isTransferOfferExpired", { enumerable: true, get: function () { return tokens_1.isTransferOfferExpired; } });
70
88
  Object.defineProperty(exports, "expiredUnclaimedLocks", { enumerable: true, get: function () { return tokens_1.expiredUnclaimedLocks; } });
89
+ Object.defineProperty(exports, "selectWalletToken", { enumerable: true, get: function () { return tokens_1.selectWalletToken; } });
71
90
  Object.defineProperty(exports, "walletTokens", { enumerable: true, get: function () { return tokens_1.walletTokens; } });
91
+ var format_1 = require("./format");
92
+ Object.defineProperty(exports, "describePreapprovalScope", { enumerable: true, get: function () { return format_1.describePreapprovalScope; } });
93
+ Object.defineProperty(exports, "formatOfferExpiry", { enumerable: true, get: function () { return format_1.formatOfferExpiry; } });
94
+ Object.defineProperty(exports, "formatTokenAmount", { enumerable: true, get: function () { return format_1.formatTokenAmount; } });
95
+ Object.defineProperty(exports, "OFFER_EXPIRY_SOON_MS", { enumerable: true, get: function () { return format_1.OFFER_EXPIRY_SOON_MS; } });
96
+ Object.defineProperty(exports, "shortCantonId", { enumerable: true, get: function () { return format_1.shortCantonId; } });
97
+ var sign_message_1 = require("./sign-message");
98
+ Object.defineProperty(exports, "readSignature", { enumerable: true, get: function () { return sign_message_1.readSignature; } });
99
+ Object.defineProperty(exports, "SIGN_MESSAGE_MAX_BYTES", { enumerable: true, get: function () { return sign_message_1.SIGN_MESSAGE_MAX_BYTES; } });
100
+ Object.defineProperty(exports, "SIGN_MESSAGE_MIN_BYTES", { enumerable: true, get: function () { return sign_message_1.SIGN_MESSAGE_MIN_BYTES; } });
101
+ Object.defineProperty(exports, "validateSignMessage", { enumerable: true, get: function () { return sign_message_1.validateSignMessage; } });
102
+ var abort_1 = require("./abort");
103
+ Object.defineProperty(exports, "MAX_TIMER_MS", { enumerable: true, get: function () { return abort_1.MAX_TIMER_MS; } });
104
+ Object.defineProperty(exports, "withTimeout", { enumerable: true, get: function () { return abort_1.withTimeout; } });
72
105
  var holdings_1 = require("./holdings");
73
106
  Object.defineProperty(exports, "isCantonCoin", { enumerable: true, get: function () { return holdings_1.isCantonCoin; } });
74
107
  var constants_1 = require("./amulet/constants");
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/wallets/index.ts"],"names":[],"mappings":";;;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AACH,qCAMmB;AALjB,8GAAA,mBAAmB,OAAA;AAMrB,iCAaiB;AAZf,+FAAA,MAAM,OAAA;AACN,0GAAA,iBAAiB,OAAA;AACjB,wGAAA,eAAe,OAAA;AAWjB,mCAiBkB;AAhBhB,sGAAA,YAAY,OAAA;AAkBd,yCAMqB;AALnB,kHAAA,qBAAqB,OAAA;AACrB,+GAAA,kBAAkB,OAAA;AAKpB,yCAaqB;AAZnB,wHAAA,2BAA2B,OAAA;AAC3B,iHAAA,oBAAoB,OAAA;AACpB,0HAAA,6BAA6B,OAAA;AAY/B,mCAqBkB;AApBhB,6GAAA,mBAAmB,OAAA;AACnB,4GAAA,kBAAkB,OAAA;AAClB,iHAAA,uBAAuB,OAAA;AACvB,8GAAA,oBAAoB,OAAA;AACpB,uGAAA,aAAa,OAAA;AACb,2GAAA,iBAAiB,OAAA;AACjB,2GAAA,iBAAiB,OAAA;AACjB,6GAAA,mBAAmB,OAAA;AACnB,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,qGAAA,WAAW,OAAA;AACX,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AAQnB,yCAQqB;AAPnB,gHAAA,mBAAmB,OAAA;AAQrB,mCAOkB;AANhB,gHAAA,sBAAsB,OAAA;AACtB,+GAAA,qBA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,aAAa,OAAA;AACb,6GAAA,mBAAmB,OAAA;AACnB,2GAAA,iBAAiB,OAAA;AACjB,2GAAA,iBAAiB,OAAA;AACjB,6GAAA,mBAAmB,OAAA;AACnB,0GAAA,gBAAgB,OAAA;AAChB,+GAAA,qBAAqB,OAAA;AACrB,qGAAA,WAAW,OAAA;AACX,2GAAA,iBAAiB,OAAA;AACjB,yGAAA,eAAe,OAAA;AACf,yGAAA,eAAe,OAAA;AACf,2GAAA,iBAAiB,OAAA;AASnB,yCAQqB;AAPnB,gHAAA,mBAAmB,OAAA;AAQrB,mCAUkB;AAThB,gHAAA,sBAAsB,OAAA;AACtB,+GAAA,qBAAqB,OAAA;AACrB,2GAAA,iBAAiB,OAAA;AACjB,sGAAA,YAAY,OAAA;AAOd,mCAQkB;AAPhB,kHAAA,wBAAwB,OAAA;AACxB,2GAAA,iBAAiB,OAAA;AACjB,2GAAA,iBAAiB,OAAA;AACjB,8GAAA,oBAAoB,OAAA;AACpB,uGAAA,aAAa,OAAA;AAIf,+CAOwB;AANtB,6GAAA,aAAa,OAAA;AACb,sHAAA,sBAAsB,OAAA;AACtB,sHAAA,sBAAsB,OAAA;AACtB,mHAAA,mBAAmB,OAAA;AAIrB,iCAAoD;AAA3C,qGAAA,YAAY,OAAA;AAAE,oGAAA,WAAW,OAAA;AAClC,uCAMoB;AALlB,wGAAA,YAAY,OAAA;AAMd,gDAK4B;AAJ1B,iHAAA,oBAAoB,OAAA;AACpB,sHAAA,yBAAyB,OAAA;AACzB,6GAAA,gBAAgB,OAAA;AAChB,iHAAA,oBAAoB,OAAA;AAGtB,+CAMwB;AALtB,uHAAA,uBAAuB,OAAA;AACvB,+GAAA,eAAe,OAAA;AAMjB,qCAAkE;AAAzD,6GAAA,kBAAkB,OAAA;AAAE,4GAAA,iBAAiB,OAAA"}
@@ -0,0 +1,70 @@
1
+ /** Who holds the latch. `label` is the caller's own code (an action type, `privy`, ...); the page words it. */
2
+ export interface WriteLatchHolder {
3
+ /** Unique per run of one latch. */
4
+ readonly id: number;
5
+ readonly label: string;
6
+ }
7
+ /** What {@link WriteLatch.getSnapshot} returns: the same object until it changes. */
8
+ export interface WriteLatchState {
9
+ /** The run holding the latch, or null when it is free. */
10
+ readonly holder: WriteLatchHolder | null;
11
+ /** Counts context changes (`bump()`). A run that started in an earlier epoch is abandoned. */
12
+ readonly epoch: number;
13
+ }
14
+ /** What a run receives. */
15
+ export interface WriteRunContext {
16
+ /** Aborted by `bump()` (a context change) or `dispose()`. Pass it to every call the run makes. */
17
+ readonly signal: AbortSignal;
18
+ /** False once the epoch the run started in has ended. */
19
+ isCurrent(): boolean;
20
+ /**
21
+ * Call it just before handing anything to a wallet or ledger to submit. An abandoned run then reports
22
+ * `unknown-outcome` instead of `dropped`.
23
+ */
24
+ markSubmitted(): void;
25
+ }
26
+ /**
27
+ * How a run ended:
28
+ *
29
+ * - `done` / `failed`: it resolved / threw in the epoch it started in;
30
+ * - `refused`: it never ran, because another run held the latch (`busy`) or the latch was disposed;
31
+ * - `dropped`: it was abandoned (a bump or dispose) before `markSubmitted()`, so nothing was sent;
32
+ * - `unknown-outcome`: it was abandoned after `markSubmitted()`, so what it sent may have committed (`error` is what it
33
+ * threw, if it threw).
34
+ */
35
+ export type WriteRunOutcome<T> = {
36
+ readonly status: 'done';
37
+ readonly value: T;
38
+ } | {
39
+ readonly status: 'failed';
40
+ readonly error: unknown;
41
+ } | {
42
+ readonly status: 'refused';
43
+ readonly reason: 'busy';
44
+ readonly holder: WriteLatchHolder;
45
+ } | {
46
+ readonly status: 'refused';
47
+ readonly reason: 'disposed';
48
+ } | {
49
+ readonly status: 'dropped';
50
+ } | {
51
+ readonly status: 'unknown-outcome';
52
+ readonly error?: unknown;
53
+ };
54
+ /** A page's single write latch. Create one with {@link createWriteLatch}. */
55
+ export interface WriteLatch {
56
+ subscribe(listener: () => void): () => void;
57
+ getSnapshot(): WriteLatchState;
58
+ /**
59
+ * Single-flight. The latch is taken synchronously, before `fn` runs (and `fn` starts synchronously), so a double
60
+ * click is refused at once. It is released when `fn` settles, only by the run that holds it. `run()` never rejects.
61
+ */
62
+ run<T>(label: string, fn: (context: WriteRunContext) => Promise<T>): Promise<WriteRunOutcome<T>>;
63
+ /** Marks every run so far as abandoned and aborts its signal. It does not free the latch: the run's own end does. */
64
+ bump(): void;
65
+ /** Abandons every run (as `bump()`), refuses new ones and stops publishing. */
66
+ dispose(): void;
67
+ }
68
+ /** A new, free {@link WriteLatch}. */
69
+ export declare function createWriteLatch(): WriteLatch;
70
+ //# sourceMappingURL=latch.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latch.d.ts","sourceRoot":"","sources":["../../../src/wallets/latch.ts"],"names":[],"mappings":"AAUA,+GAA+G;AAC/G,MAAM,WAAW,gBAAgB;IAC/B,mCAAmC;IACnC,QAAQ,CAAC,EAAE,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,qFAAqF;AACrF,MAAM,WAAW,eAAe;IAC9B,0DAA0D;IAC1D,QAAQ,CAAC,MAAM,EAAE,gBAAgB,GAAG,IAAI,CAAC;IACzC,8FAA8F;IAC9F,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAED,2BAA2B;AAC3B,MAAM,WAAW,eAAe;IAC9B,kGAAkG;IAClG,QAAQ,CAAC,MAAM,EAAE,WAAW,CAAC;IAC7B,yDAAyD;IACzD,SAAS,IAAI,OAAO,CAAC;IACrB;;;OAGG;IACH,aAAa,IAAI,IAAI,CAAC;CACvB;AAED;;;;;;;;GAQG;AACH,MAAM,MAAM,eAAe,CAAC,CAAC,IACzB;IAAE,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,CAAC,CAAA;CAAE,GAC9C;IAAE,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC;IAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,CAAA;CAAE,GACtD;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,GAC1F;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,UAAU,CAAA;CAAE,GAC3D;IAAE,QAAQ,CAAC,MAAM,EAAE,SAAS,CAAA;CAAE,GAC9B;IAAE,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,KAAK,CAAC,EAAE,OAAO,CAAA;CAAE,CAAC;AAErE,6EAA6E;AAC7E,MAAM,WAAW,UAAU;IACzB,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;IAC5C,WAAW,IAAI,eAAe,CAAC;IAC/B;;;OAGG;IACH,GAAG,CAAC,CAAC,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,OAAO,EAAE,eAAe,KAAK,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,eAAe,CAAC,CAAC,CAAC,CAAC,CAAC;IACjG,qHAAqH;IACrH,IAAI,IAAI,IAAI,CAAC;IACb,+EAA+E;IAC/E,OAAO,IAAI,IAAI,CAAC;CACjB;AAED,sCAAsC;AACtC,wBAAgB,gBAAgB,IAAI,UAAU,CA8E7C"}
@@ -0,0 +1,100 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createWriteLatch = createWriteLatch;
4
+ /**
5
+ * One write at a time for a whole page: a single-flight latch that a wallet store's actions, other writes (a Canton
6
+ * Coin prepare, sign and submit) and wallet setup steps share, so signature requests never stack or interleave. Its
7
+ * epoch counts context changes (a disconnect, another wallet or party): a run that started in an earlier epoch is
8
+ * abandoned, its signal aborts, and it reports whether it had handed anything to a wallet.
9
+ *
10
+ * Observable for any UI framework: `subscribe` and `getSnapshot`.
11
+ */
12
+ const notify_1 = require("./notify");
13
+ /** A new, free {@link WriteLatch}. */
14
+ function createWriteLatch() {
15
+ const listeners = new Set();
16
+ let state = Object.freeze({ holder: null, epoch: 0 });
17
+ let nextId = 1;
18
+ let disposed = false;
19
+ // The controllers of runs in flight; bump() and dispose() abort them all.
20
+ const running = new Set();
21
+ function commit(next) {
22
+ state = Object.freeze(next);
23
+ if (!disposed)
24
+ (0, notify_1.notifyListeners)(listeners);
25
+ }
26
+ /** Read through a call, so a check after an await is not narrowed by one before it. */
27
+ function holderId() {
28
+ return state.holder?.id ?? null;
29
+ }
30
+ function abandonAll() {
31
+ for (const controller of [...running])
32
+ controller.abort();
33
+ }
34
+ return {
35
+ subscribe(listener) {
36
+ listeners.add(listener);
37
+ return () => {
38
+ listeners.delete(listener);
39
+ };
40
+ },
41
+ getSnapshot: () => state,
42
+ async run(label, fn) {
43
+ if (disposed)
44
+ return { status: 'refused', reason: 'disposed' };
45
+ if (state.holder !== null)
46
+ return { status: 'refused', reason: 'busy', holder: state.holder };
47
+ const holder = Object.freeze({ id: nextId, label });
48
+ nextId += 1;
49
+ const { epoch } = state;
50
+ const controller = new AbortController();
51
+ running.add(controller);
52
+ let submitted = false;
53
+ const isCurrent = () => !disposed && state.epoch === epoch;
54
+ const context = {
55
+ signal: controller.signal,
56
+ isCurrent,
57
+ markSubmitted: () => {
58
+ submitted = true;
59
+ },
60
+ };
61
+ commit({ holder, epoch: state.epoch });
62
+ let outcome;
63
+ try {
64
+ const value = await fn(context);
65
+ outcome = isCurrent() ? { status: 'done', value } : abandoned(submitted);
66
+ }
67
+ catch (error) {
68
+ outcome = isCurrent() ? { status: 'failed', error } : abandoned(submitted, error);
69
+ }
70
+ finally {
71
+ running.delete(controller);
72
+ // A stale or repeated release changes nothing: only the holder frees the latch.
73
+ if (holderId() === holder.id)
74
+ commit({ holder: null, epoch: state.epoch });
75
+ }
76
+ return outcome;
77
+ },
78
+ bump() {
79
+ if (disposed)
80
+ return;
81
+ commit({ holder: state.holder, epoch: state.epoch + 1 });
82
+ abandonAll();
83
+ },
84
+ dispose() {
85
+ if (disposed)
86
+ return;
87
+ disposed = true;
88
+ state = Object.freeze({ holder: state.holder, epoch: state.epoch + 1 });
89
+ abandonAll();
90
+ listeners.clear();
91
+ },
92
+ };
93
+ }
94
+ /** What an abandoned run reports: before it handed anything over nothing was sent; after, the outcome is unknown. */
95
+ function abandoned(submitted, ...error) {
96
+ if (!submitted)
97
+ return { status: 'dropped' };
98
+ return error.length > 0 ? { status: 'unknown-outcome', error: error[0] } : { status: 'unknown-outcome' };
99
+ }
100
+ //# sourceMappingURL=latch.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"latch.js","sourceRoot":"","sources":["../../../src/wallets/latch.ts"],"names":[],"mappings":";;;AAAA;;;;;;;GAOG;AACH,qCAA2C;AA8D3C,sCAAsC;AACtC;IACE,MAAM,SAAS,GAAG,IAAI,GAAG,EAAc,CAAC;IACxC,IAAI,KAAK,GAAoB,MAAM,CAAC,MAAM,CAAC,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,EAAE,CAAC,CAAC;IACvE,IAAI,MAAM,GAAG,CAAC,CAAC;IACf,IAAI,QAAQ,GAAG,KAAK,CAAC;IACrB,0EAA0E;IAC1E,MAAM,OAAO,GAAG,IAAI,GAAG,EAAmB,CAAC;IAE3C,SAAS,MAAM,CAAC,IAAqB;QACnC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC5B,IAAI,CAAC,QAAQ;YAAE,IAAA,wBAAe,EAAC,SAAS,CAAC,CAAC;IAC5C,CAAC;IAED,uFAAuF;IACvF,SAAS,QAAQ;QACf,OAAO,KAAK,CAAC,MAAM,EAAE,EAAE,IAAI,IAAI,CAAC;IAClC,CAAC;IAED,SAAS,UAAU;QACjB,KAAK,MAAM,UAAU,IAAI,CAAC,GAAG,OAAO,CAAC;YAAE,UAAU,CAAC,KAAK,EAAE,CAAC;IAC5D,CAAC;IAED,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AG,KAAiB;IAC5D,IAAI,CAAC,SAAS;QAAE,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,CAAC;IAC7C,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,iBAAiB,EAAE,CAAC;AAC3G,CAAC"}
@@ -0,0 +1,36 @@
1
+ import type { Cip103Provider } from './cip103';
2
+ import type { DaNetwork } from './da-utilities/client';
3
+ import type { LoadedWalletOption } from './options';
4
+ /** The part of `@fivenorth/loop-sdk`'s `loop` the option uses, structurally. */
5
+ export interface LoopSdkLike {
6
+ init(options: {
7
+ readonly appName: string;
8
+ readonly network: DaNetwork;
9
+ }): void;
10
+ getCip103Provider(): Cip103Provider | Promise<Cip103Provider>;
11
+ }
12
+ /** {@link loopWalletOption}'s input. */
13
+ export interface LoopWalletOptionInput {
14
+ /** The app name Loop shows the user. */
15
+ readonly appName: string;
16
+ /**
17
+ * Loads Loop's SDK: a function that dynamically imports `@fivenorth/loop-sdk` and resolves its `loop` export (the
18
+ * app's bundler then splits Loop into its own chunk).
19
+ */
20
+ readonly load: () => Promise<LoopSdkLike>;
21
+ }
22
+ /** Loop as a {@link LoadedWalletOption}, with the network it is set up for. */
23
+ export interface LoopWalletOption extends LoadedWalletOption {
24
+ /** The network this page load set Loop up for, or null before the first `load` (or after a failed setup). */
25
+ setUpFor(): DaNetwork | null;
26
+ }
27
+ /**
28
+ * Loop as a `LoadedWalletOption` (`key: "loop"`, `kind: "loop"`, `name: "Loop"`). Loop serves one network per page load
29
+ * (a second `init` answers 4900 until a reload), so the option remembers the first network it was set up for. Create it
30
+ * once per page load, at module level. `availability(other)` then reports `reload-required` with `setUpFor`, and
31
+ * `load(other)` rejects `WalletOptionError("reload-required")`. A failed setup is forgotten, so the next `load` tries
32
+ * again (`WalletOptionError("setup-failed", { cause })`). Concurrent loads share one setup; a load's `signal` only
33
+ * stops that caller waiting.
34
+ */
35
+ export declare function loopWalletOption(input: LoopWalletOptionInput): LoopWalletOption;
36
+ //# sourceMappingURL=loop.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"loop.d.ts","sourceRoot":"","sources":["../../../src/wallets/loop.ts"],"names":[],"mappings":"AAKA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAEvD,OAAO,KAAK,EAAE,kBAAkB,EAAsB,MAAM,WAAW,CAAC;AAExE,gFAAgF;AAChF,MAAM,WAAW,WAAW;IAC1B,IAAI,CAAC,OAAO,EAAE;QAAE,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAA;KAAE,GAAG,IAAI,CAAC;IAC/E,iBAAiB,IAAI,cAAc,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CAC/D;AAED,wCAAwC;AACxC,MAAM,WAAW,qBAAqB;IACpC,wCAAwC;IACxC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;IACzB;;;OAGG;IACH,QAAQ,CAAC,IAAI,EAAE,MAAM,OAAO,CAAC,WAAW,CAAC,CAAC;CAC3C;AAED,+EAA+E;AAC/E,MAAM,WAAW,gBAAiB,SAAQ,kBAAkB;IAC1D,6GAA6G;IAC7G,QAAQ,IAAI,SAAS,GAAG,IAAI,CAAC;CAC9B;AAID;;;;;;;GAOG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,qBAAqB,GAAG,gBAAgB,CAwC/E"}
@@ -0,0 +1,59 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.loopWalletOption = loopWalletOption;
4
+ /**
5
+ * Loop (`@fivenorth/loop-sdk`) as a wallet option. node-sdk does not depend on Loop: the app passes the SDK's dynamic
6
+ * import, and the option uses only the part {@link LoopSdkLike} names.
7
+ */
8
+ const abort_1 = require("./abort");
9
+ const errors_1 = require("./errors");
10
+ const AVAILABLE = Object.freeze({ available: true });
11
+ /**
12
+ * Loop as a `LoadedWalletOption` (`key: "loop"`, `kind: "loop"`, `name: "Loop"`). Loop serves one network per page load
13
+ * (a second `init` answers 4900 until a reload), so the option remembers the first network it was set up for. Create it
14
+ * once per page load, at module level. `availability(other)` then reports `reload-required` with `setUpFor`, and
15
+ * `load(other)` rejects `WalletOptionError("reload-required")`. A failed setup is forgotten, so the next `load` tries
16
+ * again (`WalletOptionError("setup-failed", { cause })`). Concurrent loads share one setup; a load's `signal` only
17
+ * stops that caller waiting.
18
+ */
19
+ function loopWalletOption(input) {
20
+ let setup = null;
21
+ async function start(network) {
22
+ const provider = (async () => {
23
+ const loop = await input.load();
24
+ loop.init({ appName: input.appName, network });
25
+ // Structurally a CIP-0103 provider (request, on, removeListener); node-sdk validates every reply.
26
+ return loop.getCip103Provider();
27
+ })().catch((error) => {
28
+ if (setup?.provider === provider)
29
+ setup = null; // the next attempt tries again
30
+ throw new errors_1.WalletOptionError('setup-failed', { requested: network, cause: error });
31
+ });
32
+ // A caller that stopped waiting leaves no unhandled rejection; the next caller sees the failure.
33
+ provider.catch(() => undefined);
34
+ setup = { network, provider };
35
+ return provider;
36
+ }
37
+ return {
38
+ mode: 'load',
39
+ key: 'loop',
40
+ kind: 'loop',
41
+ name: 'Loop',
42
+ availability(network) {
43
+ if (setup !== null && setup.network !== network) {
44
+ return { available: false, reason: 'reload-required', setUpFor: setup.network };
45
+ }
46
+ return AVAILABLE;
47
+ },
48
+ async load(network, signal) {
49
+ if (setup !== null && setup.network !== network) {
50
+ throw new errors_1.WalletOptionError('reload-required', { setUpFor: setup.network, requested: network });
51
+ }
52
+ (0, abort_1.throwIfAborted)(signal);
53
+ const provider = setup?.provider ?? start(network);
54
+ return (0, abort_1.awaitWithAbort)(async () => provider, signal);
55
+ },
56
+ setUpFor: () => setup?.network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QACZ,YAAY,CAAC,OAAO;YAClB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAChD,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,EAAE,iBAAiB,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;YAClF,CAAC;YACD,OAAO,SAAS,CAAC;QACnB,CAAC;QACD,KAAK,CAAC,IAAI,CAAC,OAAO,EAAE,MAAM;YACxB,IAAI,KAAK,KAAK,IAAI,IAAI,KAAK,CAAC,OAAO,KAAK,OAAO,EAAE,CAAC;gBAChD,MAAM,IAAI,0BAAiB,CAAC,iBAAiB,EAAE,EAAE,QAAQ,EAAE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,CAAC,CAAC;YAClG,CAAC;YACD,IAAA,sBAAc,EAAC,MAAM,CAAC,CAAC;YACvB,MAAM,QAAQ,GAAG,KAAK,EAAE,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,CAAC;YACnD,OAAO,IAAA,sBAAc,EAAC,KAAK,IAAI,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACtD,CAAC;QACD,QAAQ,EAAE,GAAG,EAAE,CAAC,KAAK,EAAE,OAAO,IAAI,IAAI;KACvC,CAAC;AACJ,CAAC"}
@@ -0,0 +1,76 @@
1
+ /**
2
+ * The wallets a page offers to connect, as options a `createWalletConnector` drives: a wallet whose CIP-0103 provider
3
+ * is loaded on demand (Loop, a browser extension), or one the app builds over time through its own setup UI (Privy).
4
+ * Options carry codes, never sentences: the page words them.
5
+ */
6
+ import type { Cip103Provider } from './cip103';
7
+ import type { DaNetwork } from './da-utilities/client';
8
+ import { type DiscoverCip103WalletsOptions } from './discovery';
9
+ /** Whether an option can connect on a network. */
10
+ export type WalletAvailability = {
11
+ readonly available: true;
12
+ }
13
+ /** No DA network (null), or the option does not run on it. */
14
+ | {
15
+ readonly available: false;
16
+ readonly reason: 'unsupported-network';
17
+ }
18
+ /** The option is set up for another network in this page load (Loop): a reload is needed. */
19
+ | {
20
+ readonly available: false;
21
+ readonly reason: 'reload-required';
22
+ readonly setUpFor: DaNetwork;
23
+ }
24
+ /** The app has not configured the option. */
25
+ | {
26
+ readonly available: false;
27
+ readonly reason: 'not-configured';
28
+ };
29
+ /** The display facts of an option. */
30
+ export interface WalletOptionInfo {
31
+ /** Unique and stable across visits; it is what gets remembered. `loop`, `extension:<id>`, `privy`, ... */
32
+ readonly key: string;
33
+ /** For the page's icon and wording: `loop`, `extension`, `privy`, or an app's own kind. */
34
+ readonly kind: string;
35
+ readonly name: string;
36
+ /** A data URL or URL of its icon. */
37
+ readonly icon?: string;
38
+ }
39
+ /** A wallet whose CIP-0103 provider is loaded on demand: Loop, a browser extension. */
40
+ export interface LoadedWalletOption extends WalletOptionInfo {
41
+ readonly mode: 'load';
42
+ availability(network: DaNetwork): WalletAvailability;
43
+ /** Resolves the provider. A rejection is shown as `load-failed`. `signal` aborts a load nobody waits for anymore. */
44
+ load(network: DaNetwork, signal: AbortSignal): Promise<Cip103Provider>;
45
+ }
46
+ /**
47
+ * A wallet the app builds over time, through its own setup UI (Privy: login, wallet, party). It offers a provider only
48
+ * once its setup is done, and offers a new one whenever that setup changes.
49
+ */
50
+ export interface LiveWalletOption extends WalletOptionInfo {
51
+ readonly mode: 'live';
52
+ availability(network: DaNetwork): WalletAvailability;
53
+ readonly live: {
54
+ subscribe(listener: () => void): () => void;
55
+ /** The provider the option offers now, or null (not set up yet, or torn down). Compared by identity. */
56
+ getProvider(): Cip103Provider | null;
57
+ /**
58
+ * What the provider signs as (Privy: the party id), so a rebuilt provider for the same party keeps the page mounted
59
+ * and its snapshot shown. Null: use the session wallet's own key.
60
+ */
61
+ getRetainKey(): string | null;
62
+ /**
63
+ * The connector found this option remembered from an earlier visit. The option starts its own silent recovery
64
+ * (Privy: one party load once logged in). Called at most once per connector.
65
+ */
66
+ restore(): void;
67
+ };
68
+ }
69
+ /** A wallet the page offers. */
70
+ export type WalletOption = LoadedWalletOption | LiveWalletOption;
71
+ /**
72
+ * The CIP-0103 browser extensions installed here (`discoverCip103Wallets`), as options keyed `extension:<id>` with kind
73
+ * `extension`. Each is available on both DA networks.
74
+ */
75
+ export declare function extensionWalletOptions(options?: DiscoverCip103WalletsOptions): Promise<LoadedWalletOption[]>;
76
+ //# sourceMappingURL=options.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.d.ts","sourceRoot":"","sources":["../../../src/wallets/options.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,UAAU,CAAC;AAC/C,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAyB,KAAK,4BAA4B,EAAE,MAAM,aAAa,CAAC;AAEvF,kDAAkD;AAClD,MAAM,MAAM,kBAAkB,GAC1B;IAAE,QAAQ,CAAC,SAAS,EAAE,IAAI,CAAA;CAAE;AAC9B,8DAA8D;GAC5D;IAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,qBAAqB,CAAA;CAAE;AACvE,6FAA6F;GAC3F;IAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,iBAAiB,CAAC;IAAC,QAAQ,CAAC,QAAQ,EAAE,SAAS,CAAA;CAAE;AACjG,6CAA6C;GAC3C;IAAE,QAAQ,CAAC,SAAS,EAAE,KAAK,CAAC;IAAC,QAAQ,CAAC,MAAM,EAAE,gBAAgB,CAAA;CAAE,CAAC;AAErE,sCAAsC;AACtC,MAAM,WAAW,gBAAgB;IAC/B,0GAA0G;IAC1G,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,2FAA2F;IAC3F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,qCAAqC;IACrC,QAAQ,CAAC,IAAI,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,uFAAuF;AACvF,MAAM,WAAW,kBAAmB,SAAQ,gBAAgB;IAC1D,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,OAAO,EAAE,SAAS,GAAG,kBAAkB,CAAC;IACrD,qHAAqH;IACrH,IAAI,CAAC,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,cAAc,CAAC,CAAC;CACxE;AAED;;;GAGG;AACH,MAAM,WAAW,gBAAiB,SAAQ,gBAAgB;IACxD,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,YAAY,CAAC,OAAO,EAAE,SAAS,GAAG,kBAAkB,CAAC;IACrD,QAAQ,CAAC,IAAI,EAAE;QACb,SAAS,CAAC,QAAQ,EAAE,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC;QAC5C,wGAAwG;QACxG,WAAW,IAAI,cAAc,GAAG,IAAI,CAAC;QACrC;;;WAGG;QACH,YAAY,IAAI,MAAM,GAAG,IAAI,CAAC;QAC9B;;;WAGG;QACH,OAAO,IAAI,IAAI,CAAC;KACjB,CAAC;CACH;AAED,gCAAgC;AAChC,MAAM,MAAM,YAAY,GAAG,kBAAkB,GAAG,gBAAgB,CAAC;AAIjE;;;GAGG;AACH,wBAAsB,sBAAsB,CAAC,OAAO,CAAC,EAAE,4BAA4B,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC,CAUlH"}
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.extensionWalletOptions = extensionWalletOptions;
4
+ const discovery_1 = require("./discovery");
5
+ const AVAILABLE = Object.freeze({ available: true });
6
+ /**
7
+ * The CIP-0103 browser extensions installed here (`discoverCip103Wallets`), as options keyed `extension:<id>` with kind
8
+ * `extension`. Each is available on both DA networks.
9
+ */
10
+ async function extensionWalletOptions(options) {
11
+ return (await (0, discovery_1.discoverCip103Wallets)(options)).map((wallet) => ({
12
+ mode: 'load',
13
+ key: `extension:${wallet.id}`,
14
+ kind: 'extension',
15
+ name: wallet.name,
16
+ ...(wallet.icon !== undefined && { icon: wallet.icon }),
17
+ availability: () => AVAILABLE,
18
+ load: async (network, signal) => wallet.load(network, { signal }),
19
+ }));
20
+ }
21
+ //# sourceMappingURL=options.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"options.js","sourceRoot":"","sources":["../../../src/wallets/options.ts"],"names":[],"mappings":";;;AAOA,2CAAuF;AA0DvF,MAAM,SAAS,GAAuB,MAAM,CAAC,MAAM,CAAC,EAAE,SAAS,EAAE,IAAI,EAAE,CAAC,CAAC;AAEzE;;;GAGG;AACI,KAAK,iCAAiC,OAAsC;IACjF,OAAO,CAAC,MAAM,IAAA,iCAAqB,EAAC,OAAO,CAAC,CAAC,CAAC,GAAG,CAAC,CAAC,MAAM,EAAsB,EAAE,CAAC,CAAC;QACjF,IAAI,EAAE,MAAM;QACZ,GAAG,EAAE,aAAa,MAAM,CAAC,EAAE,EAAE;QAC7B,IAAI,EAAE,WAAW;QACjB,IAAI,EAAE,MAAM,CAAC,IAAI;QACjB,GAAG,CAAC,MAAM,CAAC,IAAI,KAAK,SAAS,IAAI,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,CAAC;QACvD,YAAY,EAAE,GAAG,EAAE,CAAC,SAAS;QAC7B,IAAI,EAAE,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,MAAM,EAAE,CAAC;KAClE,CAAC,CAAC,CAAC;AACN,CAAC"}
@@ -1 +1 @@
1
- {"version":3,"file":"ownership.d.ts","sourceRoot":"","sources":["../../../src/wallets/ownership.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;GAeG;AACH,OAAO,EAOL,KAAK,gBAAgB,EACtB,MAAM,UAAU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AAE,KAAK,CAAC;IACzB,QAAQ,CAAC,MAAM,EAAE,+BAA+B,GAAG,sBAAsB,CAAC;IAC1E,uCAAuC;IACvC,QAAQ,CAAC,OAAO,EAAE,MAAM,CAAC;CAC1B,CAAC;AAEN,MAAM,WAAW,oCAAoC;IACnD,iHAAiH;IACjH,QAAQ,CAAC,KAAK,CAAC,EAAE,SAAS,CAAC;IAC3B,6FAA6F;IAC7F,QAAQ,CAAC,YAAY,EAAE,MAAM,CAAC;IAC9B,+EAA+E;IAC/E,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B;;;;OAIG;IACH,QAAQ,CAAC,MAAM,CAAC,EAAE,WAAW,CAAC;CAC/B;AAmDD;;;;;;GAMG;AACH,wBAAsB,6BAA6B,CACjD,UAAU,EAAE,gBAAgB,EAC5B,OAAO,EAAE,oCAAoC,GAC5C,OAAO,CAAC,sBAAsB,CAAC,CAuBjC"}
@@ -29,6 +29,7 @@ const abort_2 = require("../core/http/abort");
29
29
  const client_1 = require("./da-utilities/client");
30
30
  const errors_1 = require("./errors");
31
31
  const json_1 = require("./json");
32
+ const sign_message_1 = require("./sign-message");
32
33
  /** The first line of every ownership message. */
33
34
  exports.WALLET_OWNERSHIP_TITLE = 'Canton wallet ownership proof';
34
35
  /** The message format version, its `Version:` line. */
@@ -146,10 +147,6 @@ function parseWalletOwnershipMessage(message) {
146
147
  return null;
147
148
  return buildWalletOwnershipMessage(fields) === message ? fields : null;
148
149
  }
149
- /** The signature from a `signMessage` result (CIP-0103's `{ signature }`). */
150
- function readSignature(raw) {
151
- return (0, json_1.isRecord)(raw) ? (0, json_1.nonEmptyString)(raw['signature']) : undefined;
152
- }
153
150
  /**
154
151
  * Ask the wallet to sign the ownership message for the challenge, as the connection's party. CIP-0103 wallets sign with
155
152
  * the primary account, so another primary account, or a wallet or challenge on the other DA network, is refused before
@@ -206,7 +203,7 @@ async function proveWalletOwnership(connection, options) {
206
203
  }
207
204
  throw new errors_1.WalletSignError('failed', `The wallet did not sign the ownership message: ${(0, cip103_1.describeError)(error)}`, code);
208
205
  }
209
- const signature = readSignature(raw);
206
+ const signature = (0, sign_message_1.readSpecSignature)(raw);
210
207
  if (signature === undefined) {
211
208
  throw new errors_1.WalletSignError('failed', 'The wallet answered signMessage without a signature');
212
209
  }