@iota/wallet-standard 0.1.3 → 0.2.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.
Files changed (80) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/README.md +1 -1
  3. package/dist/cjs/detect.d.ts +1 -5
  4. package/dist/cjs/detect.js +0 -4
  5. package/dist/cjs/detect.js.map +2 -2
  6. package/dist/cjs/features/index.d.ts +11 -10
  7. package/dist/cjs/features/index.js +3 -3
  8. package/dist/cjs/features/index.js.map +2 -2
  9. package/dist/cjs/features/iotaReportTransactionEffects.d.ts +22 -0
  10. package/dist/cjs/features/{iotaSignAndExecuteTransactionBlock.js → iotaReportTransactionEffects.js} +3 -3
  11. package/dist/cjs/features/iotaReportTransactionEffects.js.map +7 -0
  12. package/dist/cjs/features/iotaSignAndExecuteTransaction.d.ts +29 -0
  13. package/dist/cjs/features/iotaSignAndExecuteTransaction.js +17 -0
  14. package/dist/cjs/features/iotaSignAndExecuteTransaction.js.map +7 -0
  15. package/dist/cjs/features/iotaSignPersonalMessage.d.ts +2 -0
  16. package/dist/cjs/features/iotaSignPersonalMessage.js.map +1 -1
  17. package/dist/cjs/features/iotaSignTransaction.d.ts +34 -0
  18. package/dist/cjs/features/{iotaSignTransactionBlock.js → iotaSignTransaction.js} +3 -3
  19. package/dist/cjs/features/iotaSignTransaction.js.map +7 -0
  20. package/dist/cjs/index.d.ts +2 -1
  21. package/dist/cjs/index.js +10 -0
  22. package/dist/cjs/index.js.map +2 -2
  23. package/dist/cjs/types.d.ts +156 -0
  24. package/dist/cjs/{features/iotaSignMessage.js → types.js} +3 -3
  25. package/dist/cjs/types.js.map +7 -0
  26. package/dist/cjs/wallet.d.ts +7 -0
  27. package/dist/cjs/wallet.js +24 -0
  28. package/dist/cjs/wallet.js.map +2 -2
  29. package/dist/esm/detect.d.ts +1 -5
  30. package/dist/esm/detect.js +0 -4
  31. package/dist/esm/detect.js.map +2 -2
  32. package/dist/esm/features/index.d.ts +11 -10
  33. package/dist/esm/features/index.js +3 -3
  34. package/dist/esm/features/index.js.map +2 -2
  35. package/dist/esm/features/iotaReportTransactionEffects.d.ts +22 -0
  36. package/dist/esm/features/iotaReportTransactionEffects.js +1 -0
  37. package/dist/esm/features/iotaSignAndExecuteTransaction.d.ts +29 -0
  38. package/dist/esm/features/iotaSignAndExecuteTransaction.js +1 -0
  39. package/dist/esm/features/iotaSignPersonalMessage.d.ts +2 -0
  40. package/dist/esm/features/iotaSignTransaction.d.ts +34 -0
  41. package/dist/esm/features/iotaSignTransaction.js +1 -0
  42. package/dist/esm/index.d.ts +2 -1
  43. package/dist/esm/index.js +6 -0
  44. package/dist/esm/index.js.map +2 -2
  45. package/dist/esm/types.d.ts +156 -0
  46. package/dist/esm/types.js +1 -0
  47. package/dist/esm/types.js.map +7 -0
  48. package/dist/esm/wallet.d.ts +7 -0
  49. package/dist/esm/wallet.js +20 -0
  50. package/dist/esm/wallet.js.map +3 -3
  51. package/dist/tsconfig.esm.tsbuildinfo +1 -1
  52. package/dist/tsconfig.tsbuildinfo +1 -1
  53. package/package.json +7 -5
  54. package/src/detect.ts +2 -11
  55. package/src/features/index.ts +20 -21
  56. package/src/features/iotaReportTransactionEffects.ts +31 -0
  57. package/src/features/iotaSignAndExecuteTransaction.ts +40 -0
  58. package/src/features/iotaSignPersonalMessage.ts +2 -0
  59. package/src/features/iotaSignTransaction.ts +44 -0
  60. package/src/index.ts +2 -1
  61. package/src/types.ts +173 -0
  62. package/src/wallet.ts +38 -0
  63. package/dist/cjs/features/iotaSignAndExecuteTransactionBlock.d.ts +0 -31
  64. package/dist/cjs/features/iotaSignAndExecuteTransactionBlock.js.map +0 -7
  65. package/dist/cjs/features/iotaSignMessage.d.ts +0 -38
  66. package/dist/cjs/features/iotaSignMessage.js.map +0 -7
  67. package/dist/cjs/features/iotaSignTransactionBlock.d.ts +0 -30
  68. package/dist/cjs/features/iotaSignTransactionBlock.js.map +0 -7
  69. package/dist/esm/features/iotaSignAndExecuteTransactionBlock.d.ts +0 -31
  70. package/dist/esm/features/iotaSignAndExecuteTransactionBlock.js +0 -1
  71. package/dist/esm/features/iotaSignMessage.d.ts +0 -38
  72. package/dist/esm/features/iotaSignMessage.js +0 -1
  73. package/dist/esm/features/iotaSignTransactionBlock.d.ts +0 -30
  74. package/dist/esm/features/iotaSignTransactionBlock.js +0 -1
  75. package/src/features/iotaSignAndExecuteTransactionBlock.ts +0 -46
  76. package/src/features/iotaSignMessage.ts +0 -47
  77. package/src/features/iotaSignTransactionBlock.ts +0 -41
  78. /package/dist/esm/features/{iotaSignAndExecuteTransactionBlock.js.map → iotaReportTransactionEffects.js.map} +0 -0
  79. /package/dist/esm/features/{iotaSignMessage.js.map → iotaSignAndExecuteTransaction.js.map} +0 -0
  80. /package/dist/esm/features/{iotaSignTransactionBlock.js.map → iotaSignTransaction.js.map} +0 -0
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/wallet.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\ndeclare module '@wallet-standard/core' {\n export interface Wallet {\n /**\n * Unique identifier of the Wallet.\n *\n * If not provided, the wallet name will be used as the identifier.\n */\n readonly id?: string;\n }\n}\n\nexport type { Wallet } from '@wallet-standard/core';\n"],
5
- "mappings": ";;;;;;;;;;;;;;AAAA;AAAA;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { WalletWithFeatures } from '@wallet-standard/core';\n\nimport type {\n IotaSignAndExecuteTransactionInput,\n IotaSignTransactionInput,\n IotaWalletFeatures,\n} from './features/index.js';\n\ndeclare module '@wallet-standard/core' {\n export interface Wallet {\n /**\n * Unique identifier of the Wallet.\n *\n * If not provided, the wallet name will be used as the identifier.\n */\n readonly id?: string;\n }\n\n export interface StandardConnectOutput {\n supportedIntents?: string[];\n }\n}\n\nexport type { Wallet } from '@wallet-standard/core';\n\nexport async function signAndExecuteTransaction(\n wallet: WalletWithFeatures<Partial<IotaWalletFeatures>>,\n input: IotaSignAndExecuteTransactionInput,\n) {\n if (!wallet.features['iota:signAndExecuteTransaction']) {\n throw new Error(\n `Provided wallet (${wallet.name}) does not support the signAndExecuteTransaction feature.`,\n );\n }\n\n return wallet.features['iota:signAndExecuteTransaction'].signAndExecuteTransaction(input);\n}\n\nexport async function signTransaction(\n wallet: WalletWithFeatures<Partial<IotaWalletFeatures>>,\n input: IotaSignTransactionInput,\n) {\n if (!wallet.features['iota:signTransaction']) {\n throw new Error(\n `Provided wallet (${wallet.name}) does not support the signTransaction feature.`,\n );\n }\n\n return wallet.features['iota:signTransaction'].signTransaction(input);\n}\n"],
5
+ "mappings": ";;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AA6BA,eAAsB,0BAClB,QACA,OACF;AACE,MAAI,CAAC,OAAO,SAAS,gCAAgC,GAAG;AACpD,UAAM,IAAI;AAAA,MACN,oBAAoB,OAAO,IAAI;AAAA,IACnC;AAAA,EACJ;AAEA,SAAO,OAAO,SAAS,gCAAgC,EAAE,0BAA0B,KAAK;AAC5F;AAEA,eAAsB,gBAClB,QACA,OACF;AACE,MAAI,CAAC,OAAO,SAAS,sBAAsB,GAAG;AAC1C,UAAM,IAAI;AAAA,MACN,oBAAoB,OAAO,IAAI;AAAA,IACnC;AAAA,EACJ;AAEA,SAAO,OAAO,SAAS,sBAAsB,EAAE,gBAAgB,KAAK;AACxE;",
6
6
  "names": []
7
7
  }
@@ -1,7 +1,3 @@
1
1
  import type { Wallet, WalletWithFeatures } from '@wallet-standard/core';
2
- import type { MinimallyRequiredFeatures, WalletWithIotaFeatures } from './features/index.js';
3
- /** @deprecated Use isWalletWithRequiredFeatureSet instead since it provides more accurate typing! */
4
- export declare function isWalletWithIotaFeatures(wallet: Wallet,
5
- /** Extra features that are required to be present, in addition to the expected feature set. */
6
- features?: string[]): wallet is WalletWithIotaFeatures;
2
+ import type { MinimallyRequiredFeatures } from './features/index.js';
7
3
  export declare function isWalletWithRequiredFeatureSet<AdditionalFeatures extends Wallet['features']>(wallet: Wallet, additionalFeatures?: (keyof AdditionalFeatures)[]): wallet is WalletWithFeatures<MinimallyRequiredFeatures & AdditionalFeatures>;
@@ -2,16 +2,12 @@ const REQUIRED_FEATURES = [
2
2
  "standard:connect",
3
3
  "standard:events"
4
4
  ];
5
- function isWalletWithIotaFeatures(wallet, features = []) {
6
- return [...REQUIRED_FEATURES, ...features].every((feature) => feature in wallet.features);
7
- }
8
5
  function isWalletWithRequiredFeatureSet(wallet, additionalFeatures = []) {
9
6
  return [...REQUIRED_FEATURES, ...additionalFeatures].every(
10
7
  (feature) => feature in wallet.features
11
8
  );
12
9
  }
13
10
  export {
14
- isWalletWithIotaFeatures,
15
11
  isWalletWithRequiredFeatureSet
16
12
  };
17
13
  //# sourceMappingURL=detect.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/detect.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Wallet, WalletWithFeatures } from '@wallet-standard/core';\n\nimport type { MinimallyRequiredFeatures, WalletWithIotaFeatures } from './features/index.js';\n\n// These features are absolutely required for wallets to function in the Iota ecosystem.\n// Eventually, as wallets have more consistent support of features, we may want to extend this list.\nconst REQUIRED_FEATURES: (keyof MinimallyRequiredFeatures)[] = [\n 'standard:connect',\n 'standard:events',\n];\n\n/** @deprecated Use isWalletWithRequiredFeatureSet instead since it provides more accurate typing! */\nexport function isWalletWithIotaFeatures(\n wallet: Wallet,\n /** Extra features that are required to be present, in addition to the expected feature set. */\n features: string[] = [],\n): wallet is WalletWithIotaFeatures {\n return [...REQUIRED_FEATURES, ...features].every((feature) => feature in wallet.features);\n}\n\nexport function isWalletWithRequiredFeatureSet<AdditionalFeatures extends Wallet['features']>(\n wallet: Wallet,\n additionalFeatures: (keyof AdditionalFeatures)[] = [],\n): wallet is WalletWithFeatures<MinimallyRequiredFeatures & AdditionalFeatures> {\n return [...REQUIRED_FEATURES, ...additionalFeatures].every(\n (feature) => feature in wallet.features,\n );\n}\n"],
5
- "mappings": "AAUA,MAAM,oBAAyD;AAAA,EAC3D;AAAA,EACA;AACJ;AAGO,SAAS,yBACZ,QAEA,WAAqB,CAAC,GACU;AAChC,SAAO,CAAC,GAAG,mBAAmB,GAAG,QAAQ,EAAE,MAAM,CAAC,YAAY,WAAW,OAAO,QAAQ;AAC5F;AAEO,SAAS,+BACZ,QACA,qBAAmD,CAAC,GACwB;AAC5E,SAAO,CAAC,GAAG,mBAAmB,GAAG,kBAAkB,EAAE;AAAA,IACjD,CAAC,YAAY,WAAW,OAAO;AAAA,EACnC;AACJ;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { Wallet, WalletWithFeatures } from '@wallet-standard/core';\n\nimport type { MinimallyRequiredFeatures } from './features/index.js';\n\n// These features are absolutely required for wallets to function in the IOTA ecosystem.\n// Eventually, as wallets have more consistent support of features, we may want to extend this list.\nconst REQUIRED_FEATURES: (keyof MinimallyRequiredFeatures)[] = [\n 'standard:connect',\n 'standard:events',\n];\n\nexport function isWalletWithRequiredFeatureSet<AdditionalFeatures extends Wallet['features']>(\n wallet: Wallet,\n additionalFeatures: (keyof AdditionalFeatures)[] = [],\n): wallet is WalletWithFeatures<MinimallyRequiredFeatures & AdditionalFeatures> {\n return [...REQUIRED_FEATURES, ...additionalFeatures].every(\n (feature) => feature in wallet.features,\n );\n}\n"],
5
+ "mappings": "AAUA,MAAM,oBAAyD;AAAA,EAC3D;AAAA,EACA;AACJ;AAEO,SAAS,+BACZ,QACA,qBAAmD,CAAC,GACwB;AAC5E,SAAO,CAAC,GAAG,mBAAmB,GAAG,kBAAkB,EAAE;AAAA,IACjD,CAAC,YAAY,WAAW,OAAO;AAAA,EACnC;AACJ;",
6
6
  "names": []
7
7
  }
@@ -1,19 +1,20 @@
1
1
  import type { IdentifierRecord, StandardConnectFeature, StandardDisconnectFeature, StandardEventsFeature, WalletWithFeatures } from '@wallet-standard/core';
2
- import type { IotaSignAndExecuteTransactionBlockFeature } from './iotaSignAndExecuteTransactionBlock.js';
3
- import type { IotaSignMessageFeature } from './iotaSignMessage.js';
2
+ import type { IotaReportTransactionEffectsFeature } from './iotaReportTransactionEffects.js';
3
+ import type { IotaSignAndExecuteTransactionFeature } from './iotaSignAndExecuteTransaction.js';
4
4
  import type { IotaSignPersonalMessageFeature } from './iotaSignPersonalMessage.js';
5
- import type { IotaSignTransactionBlockFeature } from './iotaSignTransactionBlock.js';
5
+ import type { IotaSignTransactionFeature } from './iotaSignTransaction.js';
6
6
  /**
7
- * Wallet Standard features that are unique to Iota, and that all Iota wallets are expected to implement.
7
+ * Wallet Standard features that are unique to IOTA, and that all IOTA wallets are expected to implement.
8
8
  */
9
- export type IotaFeatures = IotaSignTransactionBlockFeature & IotaSignAndExecuteTransactionBlockFeature & IotaSignPersonalMessageFeature & Partial<IotaSignMessageFeature>;
10
- export type WalletWithIotaFeatures = WalletWithFeatures<StandardConnectFeature & StandardEventsFeature & IotaFeatures & Partial<StandardDisconnectFeature>>;
9
+ export type IotaFeatures = IotaSignPersonalMessageFeature & IotaSignAndExecuteTransactionFeature & IotaSignTransactionFeature & Partial<IotaReportTransactionEffectsFeature>;
10
+ export type IotaWalletFeatures = StandardConnectFeature & StandardEventsFeature & IotaFeatures & Partial<StandardDisconnectFeature>;
11
+ export type WalletWithIotaFeatures = WalletWithFeatures<IotaWalletFeatures>;
11
12
  /**
12
- * Represents a wallet with the absolute minimum feature set required to function in the Iota ecosystem.
13
+ * Represents a wallet with the absolute minimum feature set required to function in the IOTA ecosystem.
13
14
  */
14
15
  export type WalletWithRequiredFeatures = WalletWithFeatures<MinimallyRequiredFeatures & Partial<IotaFeatures> & Partial<StandardDisconnectFeature> & IdentifierRecord<unknown>>;
15
16
  export type MinimallyRequiredFeatures = StandardConnectFeature & StandardEventsFeature;
16
- export * from './iotaSignMessage.js';
17
- export * from './iotaSignTransactionBlock.js';
18
- export * from './iotaSignAndExecuteTransactionBlock.js';
17
+ export * from './iotaSignTransaction.js';
18
+ export * from './iotaSignAndExecuteTransaction.js';
19
19
  export * from './iotaSignPersonalMessage.js';
20
+ export * from './iotaReportTransactionEffects.js';
@@ -1,5 +1,5 @@
1
- export * from "./iotaSignMessage.js";
2
- export * from "./iotaSignTransactionBlock.js";
3
- export * from "./iotaSignAndExecuteTransactionBlock.js";
1
+ export * from "./iotaSignTransaction.js";
2
+ export * from "./iotaSignAndExecuteTransaction.js";
4
3
  export * from "./iotaSignPersonalMessage.js";
4
+ export * from "./iotaReportTransactionEffects.js";
5
5
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../../src/features/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n IdentifierRecord,\n StandardConnectFeature,\n StandardDisconnectFeature,\n StandardEventsFeature,\n WalletWithFeatures,\n} from '@wallet-standard/core';\n\nimport type { IotaSignAndExecuteTransactionBlockFeature } from './iotaSignAndExecuteTransactionBlock.js';\nimport type { IotaSignMessageFeature } from './iotaSignMessage.js';\nimport type { IotaSignPersonalMessageFeature } from './iotaSignPersonalMessage.js';\nimport type { IotaSignTransactionBlockFeature } from './iotaSignTransactionBlock.js';\n\n/**\n * Wallet Standard features that are unique to Iota, and that all Iota wallets are expected to implement.\n */\nexport type IotaFeatures = IotaSignTransactionBlockFeature &\n IotaSignAndExecuteTransactionBlockFeature &\n IotaSignPersonalMessageFeature &\n // This deprecated feature should be removed once wallets update to the new method:\n Partial<IotaSignMessageFeature>;\n\nexport type WalletWithIotaFeatures = WalletWithFeatures<\n StandardConnectFeature &\n StandardEventsFeature &\n IotaFeatures &\n // Disconnect is an optional feature:\n Partial<StandardDisconnectFeature>\n>;\n\n/**\n * Represents a wallet with the absolute minimum feature set required to function in the Iota ecosystem.\n */\nexport type WalletWithRequiredFeatures = WalletWithFeatures<\n MinimallyRequiredFeatures &\n Partial<IotaFeatures> &\n Partial<StandardDisconnectFeature> &\n IdentifierRecord<unknown>\n>;\n\nexport type MinimallyRequiredFeatures = StandardConnectFeature & StandardEventsFeature;\n\nexport * from './iotaSignMessage.js';\nexport * from './iotaSignTransactionBlock.js';\nexport * from './iotaSignAndExecuteTransactionBlock.js';\nexport * from './iotaSignPersonalMessage.js';\n"],
5
- "mappings": "AA8CA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type {\n IdentifierRecord,\n StandardConnectFeature,\n StandardDisconnectFeature,\n StandardEventsFeature,\n WalletWithFeatures,\n} from '@wallet-standard/core';\n\nimport type { IotaReportTransactionEffectsFeature } from './iotaReportTransactionEffects.js';\nimport type { IotaSignAndExecuteTransactionFeature } from './iotaSignAndExecuteTransaction.js';\nimport type { IotaSignPersonalMessageFeature } from './iotaSignPersonalMessage.js';\nimport type { IotaSignTransactionFeature } from './iotaSignTransaction.js';\n\n/**\n * Wallet Standard features that are unique to IOTA, and that all IOTA wallets are expected to implement.\n */\nexport type IotaFeatures = IotaSignPersonalMessageFeature &\n IotaSignAndExecuteTransactionFeature &\n IotaSignTransactionFeature &\n Partial<IotaReportTransactionEffectsFeature>;\n\nexport type IotaWalletFeatures = StandardConnectFeature &\n StandardEventsFeature &\n IotaFeatures &\n // Disconnect is an optional feature:\n Partial<StandardDisconnectFeature>;\n\nexport type WalletWithIotaFeatures = WalletWithFeatures<IotaWalletFeatures>;\n\n/**\n * Represents a wallet with the absolute minimum feature set required to function in the IOTA ecosystem.\n */\nexport type WalletWithRequiredFeatures = WalletWithFeatures<\n MinimallyRequiredFeatures &\n Partial<IotaFeatures> &\n Partial<StandardDisconnectFeature> &\n IdentifierRecord<unknown>\n>;\n\nexport type MinimallyRequiredFeatures = StandardConnectFeature & StandardEventsFeature;\n\nexport * from './iotaSignTransaction.js';\nexport * from './iotaSignAndExecuteTransaction.js';\nexport * from './iotaSignPersonalMessage.js';\nexport * from './iotaReportTransactionEffects.js';\n"],
5
+ "mappings": "AA6CA,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,22 @@
1
+ import type { IdentifierString, WalletAccount } from '@wallet-standard/core';
2
+ /**
3
+ * A Wallet Standard feature for reporting the effects of a transaction block executed by a dapp
4
+ * The feature allows wallets to updated their caches using the effects of the transaction
5
+ * executed outside of the wallet
6
+ */
7
+ export type IotaReportTransactionEffectsFeature = {
8
+ /** Namespace for the feature. */
9
+ 'iota:reportTransactionEffects': {
10
+ /** Version of the feature API. */
11
+ version: '1.0.0';
12
+ reportTransactionEffects: IotaReportTransactionEffectsMethod;
13
+ };
14
+ };
15
+ export type IotaReportTransactionEffectsMethod = (input: IotaReportTransactionEffectsInput) => Promise<void>;
16
+ /** Input for signing transactions. */
17
+ export interface IotaReportTransactionEffectsInput {
18
+ account: WalletAccount;
19
+ chain: IdentifierString;
20
+ /** Transaction effects as base64 encoded bcs. */
21
+ effects: string;
22
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=iotaReportTransactionEffects.js.map
@@ -0,0 +1,29 @@
1
+ import type { IotaTransactionBlockResponseOptions } from '@iota/iota-sdk/client';
2
+ import type { SignedTransaction, IotaSignTransactionInput } from './iotaSignTransaction.js';
3
+ /** The latest API version of the signAndExecuteTransactionBlock API. */
4
+ export type IotaSignAndExecuteTransactionVersion = '2.0.0';
5
+ /**
6
+ * A Wallet Standard feature for signing a transaction, and submitting it to the
7
+ * network. The wallet is expected to submit the transaction to the network via RPC,
8
+ * and return the transaction response.
9
+ */
10
+ export type IotaSignAndExecuteTransactionFeature = {
11
+ /** Namespace for the feature. */
12
+ 'iota:signAndExecuteTransaction': {
13
+ /** Version of the feature API. */
14
+ version: IotaSignAndExecuteTransactionVersion;
15
+ signAndExecuteTransaction: IotaSignAndExecuteTransactionMethod;
16
+ };
17
+ };
18
+ export type IotaSignAndExecuteTransactionMethod = (input: IotaSignAndExecuteTransactionInput) => Promise<IotaSignAndExecuteTransactionOutput>;
19
+ /** Input for signing and sending transactions. */
20
+ export interface IotaSignAndExecuteTransactionInput extends IotaSignTransactionInput {
21
+ /** specify which fields to return (e.g., transaction, effects, events, etc). By default, only the transaction digest will be returned. */
22
+ options?: IotaTransactionBlockResponseOptions;
23
+ }
24
+ /** Output of signing and sending transactions. */
25
+ export interface IotaSignAndExecuteTransactionOutput extends SignedTransaction {
26
+ digest: string;
27
+ /** Transaction effects as base64 encoded bcs. */
28
+ effects: string;
29
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=iotaSignAndExecuteTransaction.js.map
@@ -23,6 +23,8 @@ export interface IotaSignPersonalMessageInput {
23
23
  export interface IotaSignPersonalMessageOutput extends SignedPersonalMessage {
24
24
  }
25
25
  export interface SignedPersonalMessage {
26
+ /** Base64 encoded message bytes */
26
27
  bytes: string;
28
+ /** Base64 encoded signature */
27
29
  signature: string;
28
30
  }
@@ -0,0 +1,34 @@
1
+ import type { IdentifierString, WalletAccount } from '@wallet-standard/core';
2
+ /** The latest API version of the signTransaction API. */
3
+ export type IotaSignTransactionVersion = '2.0.0';
4
+ /**
5
+ * A Wallet Standard feature for signing a transaction, and returning the
6
+ * serialized transaction and transaction signature.
7
+ */
8
+ export type IotaSignTransactionFeature = {
9
+ /** Namespace for the feature. */
10
+ 'iota:signTransaction': {
11
+ /** Version of the feature API. */
12
+ version: IotaSignTransactionVersion;
13
+ signTransaction: IotaSignTransactionMethod;
14
+ };
15
+ };
16
+ export type IotaSignTransactionMethod = (input: IotaSignTransactionInput) => Promise<SignedTransaction>;
17
+ /** Input for signing transactions. */
18
+ export interface IotaSignTransactionInput {
19
+ transaction: {
20
+ toJSON: () => Promise<string>;
21
+ };
22
+ account: WalletAccount;
23
+ chain: IdentifierString;
24
+ signal?: AbortSignal;
25
+ }
26
+ /** Output of signing transactions. */
27
+ export interface SignedTransaction {
28
+ /** Transaction as base64 encoded bcs. */
29
+ bytes: string;
30
+ /** Base64 encoded signature */
31
+ signature: string;
32
+ }
33
+ export interface IotaSignTransactionOutput extends SignedTransaction {
34
+ }
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=iotaSignTransaction.js.map
@@ -1,5 +1,6 @@
1
1
  export * from '@wallet-standard/core';
2
- export type { Wallet } from './wallet.js';
2
+ export { type Wallet, signAndExecuteTransaction, signTransaction } from './wallet.js';
3
3
  export * from './features/index.js';
4
4
  export * from './detect.js';
5
5
  export * from './chains.js';
6
+ export * from './types.js';
package/dist/esm/index.js CHANGED
@@ -1,5 +1,11 @@
1
1
  export * from "@wallet-standard/core";
2
+ import { signAndExecuteTransaction, signTransaction } from "./wallet.js";
2
3
  export * from "./features/index.js";
3
4
  export * from "./detect.js";
4
5
  export * from "./chains.js";
6
+ export * from "./types.js";
7
+ export {
8
+ signAndExecuteTransaction,
9
+ signTransaction
10
+ };
5
11
  //# sourceMappingURL=index.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../../src/index.ts"],
4
- "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from '@wallet-standard/core';\n\nexport type { Wallet } from './wallet.js';\nexport * from './features/index.js';\nexport * from './detect.js';\nexport * from './chains.js';\n"],
5
- "mappings": "AAIA,cAAc;AAGd,cAAc;AACd,cAAc;AACd,cAAc;",
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nexport * from '@wallet-standard/core';\n\nexport { type Wallet, signAndExecuteTransaction, signTransaction } from './wallet.js';\nexport * from './features/index.js';\nexport * from './detect.js';\nexport * from './chains.js';\nexport * from './types.js';\n"],
5
+ "mappings": "AAIA,cAAc;AAEd,SAAsB,2BAA2B,uBAAuB;AACxE,cAAc;AACd,cAAc;AACd,cAAc;AACd,cAAc;",
6
6
  "names": []
7
7
  }
@@ -0,0 +1,156 @@
1
+ /** Contains data related to the gas payment for a Transaction */
2
+ export interface GasData {
3
+ /** The budget set for this transaction */
4
+ budget: string | number | null;
5
+ /** The gas price used for this transaction */
6
+ price: string | number | null;
7
+ /** The owner of the gas coins used to fund the transactions, this is either the sender or the gas sponsor */
8
+ owner: string | null;
9
+ /** The list of IOTA coins to fund the transaction */
10
+ payment: {
11
+ objectId: string;
12
+ version: string;
13
+ digest: string;
14
+ }[] | null;
15
+ }
16
+ /**
17
+ * Represent the serialized state of a partially built Transaction
18
+ * This format is designed to support transactions that have not been fully build
19
+ * allowing most properties to be omitted or set to null. It also supports
20
+ * unresolved object references, unresolved pure values, and Transaction Intents.
21
+ */
22
+ export interface SerializedTransactionDataV2 {
23
+ version: 2;
24
+ /** The sender of the transaction */
25
+ sender: string | null | undefined;
26
+ /** The expiration of the transaction */
27
+ expiration: {
28
+ Epoch: number;
29
+ } | {
30
+ None: true;
31
+ } | null | undefined;
32
+ /** The gas data */
33
+ gasData: GasData;
34
+ /** The inputs to the transaction */
35
+ inputs: CallArg[];
36
+ /** The commands to execute */
37
+ commands: Command[];
38
+ /** Extra metadata for implementation specific use-cases */
39
+ extensions?: {
40
+ [key: string]: unknown;
41
+ };
42
+ }
43
+ /**
44
+ * Represents an input to a Transaction, either as a fully resolved Object or Pure input
45
+ * or as an unresolved partial reference which needs to be resolved before the transaction
46
+ * can be serialized to bcs and executed.
47
+ */
48
+ export type CallArg = {
49
+ Object: ObjectArg;
50
+ } | {
51
+ Pure: PureArg;
52
+ } | {
53
+ UnresolvedPure: UnresolvedPureArg;
54
+ } | {
55
+ UnresolvedObject: UnresolvedObjectArg;
56
+ };
57
+ export type ObjectArg = {
58
+ ImmOrOwnedObject: {
59
+ objectId: string;
60
+ version: string | number;
61
+ digest: string;
62
+ };
63
+ } | {
64
+ SharedObject: {
65
+ objectId: string;
66
+ initialSharedVersion: string;
67
+ mutable: boolean;
68
+ };
69
+ } | {
70
+ Receiving: {
71
+ objectId: string;
72
+ version: string | number;
73
+ digest: string;
74
+ };
75
+ };
76
+ export interface PureArg {
77
+ bytes: string;
78
+ }
79
+ /**
80
+ * Represents an un-serialized pure value.
81
+ * The correct bcs schema will need to be determined before this value can be serialized to bcs */
82
+ export interface UnresolvedPureArg {
83
+ value: unknown;
84
+ }
85
+ /**
86
+ * Represents an unresolved object reference. This allows objects to be referenced by only their ID.
87
+ * version and digest details may also be added to unresolved object references.
88
+ * To fully resolve a reference, the correct ObjectArg type needs to be determined based on the type of object,
89
+ * and how it used in the transaction (eg, is it used mutably if it's shared, and is it a receiving object if it's not shared)
90
+ */
91
+ export interface UnresolvedObjectArg {
92
+ objectId: string;
93
+ version?: string | null | undefined;
94
+ digest?: string | null | undefined;
95
+ initialSharedVersion?: string | null | undefined;
96
+ }
97
+ export type Argument = {
98
+ GasCoin: true;
99
+ } | {
100
+ Input: number;
101
+ } | {
102
+ Result: number;
103
+ } | {
104
+ NestedResult: [number, number];
105
+ };
106
+ export type Command = {
107
+ MoveCall: {
108
+ package: string;
109
+ module: string;
110
+ function: string;
111
+ typeArguments: string[];
112
+ arguments: Argument[];
113
+ };
114
+ } | {
115
+ TransferObjects: {
116
+ objects: Argument[];
117
+ address: Argument;
118
+ };
119
+ } | {
120
+ SplitCoins: {
121
+ coin: Argument;
122
+ amounts: Argument[];
123
+ };
124
+ } | {
125
+ MergeCoins: {
126
+ destination: Argument;
127
+ sources: Argument[];
128
+ };
129
+ } | {
130
+ Publish: {
131
+ modules: string[];
132
+ dependencies: string[];
133
+ };
134
+ } | {
135
+ MakeMoveVec: {
136
+ type: string | null;
137
+ elements: Argument[];
138
+ };
139
+ } | {
140
+ Upgrade: {
141
+ modules: string[];
142
+ dependencies: string[];
143
+ package: string;
144
+ ticket: Argument;
145
+ };
146
+ } | {
147
+ $Intent: {
148
+ name: string;
149
+ inputs: {
150
+ [key: string]: Argument | Argument[];
151
+ };
152
+ data: {
153
+ [key: string]: unknown;
154
+ };
155
+ };
156
+ };
@@ -0,0 +1 @@
1
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": [],
4
+ "sourcesContent": [],
5
+ "mappings": "",
6
+ "names": []
7
+ }
@@ -1,3 +1,5 @@
1
+ import type { WalletWithFeatures } from '@wallet-standard/core';
2
+ import type { IotaSignAndExecuteTransactionInput, IotaSignTransactionInput, IotaWalletFeatures } from './features/index.js';
1
3
  declare module '@wallet-standard/core' {
2
4
  interface Wallet {
3
5
  /**
@@ -7,5 +9,10 @@ declare module '@wallet-standard/core' {
7
9
  */
8
10
  readonly id?: string;
9
11
  }
12
+ interface StandardConnectOutput {
13
+ supportedIntents?: string[];
14
+ }
10
15
  }
11
16
  export type { Wallet } from '@wallet-standard/core';
17
+ export declare function signAndExecuteTransaction(wallet: WalletWithFeatures<Partial<IotaWalletFeatures>>, input: IotaSignAndExecuteTransactionInput): Promise<import("./features/iotaSignAndExecuteTransaction.js").IotaSignAndExecuteTransactionOutput>;
18
+ export declare function signTransaction(wallet: WalletWithFeatures<Partial<IotaWalletFeatures>>, input: IotaSignTransactionInput): Promise<import("./features/iotaSignTransaction.js").SignedTransaction>;
@@ -1 +1,21 @@
1
+ async function signAndExecuteTransaction(wallet, input) {
2
+ if (!wallet.features["iota:signAndExecuteTransaction"]) {
3
+ throw new Error(
4
+ `Provided wallet (${wallet.name}) does not support the signAndExecuteTransaction feature.`
5
+ );
6
+ }
7
+ return wallet.features["iota:signAndExecuteTransaction"].signAndExecuteTransaction(input);
8
+ }
9
+ async function signTransaction(wallet, input) {
10
+ if (!wallet.features["iota:signTransaction"]) {
11
+ throw new Error(
12
+ `Provided wallet (${wallet.name}) does not support the signTransaction feature.`
13
+ );
14
+ }
15
+ return wallet.features["iota:signTransaction"].signTransaction(input);
16
+ }
17
+ export {
18
+ signAndExecuteTransaction,
19
+ signTransaction
20
+ };
1
21
  //# sourceMappingURL=wallet.js.map
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
- "sources": [],
4
- "sourcesContent": [],
5
- "mappings": "",
3
+ "sources": ["../../src/wallet.ts"],
4
+ "sourcesContent": ["// Copyright (c) Mysten Labs, Inc.\n// Modifications Copyright (c) 2024 IOTA Stiftung\n// SPDX-License-Identifier: Apache-2.0\n\nimport type { WalletWithFeatures } from '@wallet-standard/core';\n\nimport type {\n IotaSignAndExecuteTransactionInput,\n IotaSignTransactionInput,\n IotaWalletFeatures,\n} from './features/index.js';\n\ndeclare module '@wallet-standard/core' {\n export interface Wallet {\n /**\n * Unique identifier of the Wallet.\n *\n * If not provided, the wallet name will be used as the identifier.\n */\n readonly id?: string;\n }\n\n export interface StandardConnectOutput {\n supportedIntents?: string[];\n }\n}\n\nexport type { Wallet } from '@wallet-standard/core';\n\nexport async function signAndExecuteTransaction(\n wallet: WalletWithFeatures<Partial<IotaWalletFeatures>>,\n input: IotaSignAndExecuteTransactionInput,\n) {\n if (!wallet.features['iota:signAndExecuteTransaction']) {\n throw new Error(\n `Provided wallet (${wallet.name}) does not support the signAndExecuteTransaction feature.`,\n );\n }\n\n return wallet.features['iota:signAndExecuteTransaction'].signAndExecuteTransaction(input);\n}\n\nexport async function signTransaction(\n wallet: WalletWithFeatures<Partial<IotaWalletFeatures>>,\n input: IotaSignTransactionInput,\n) {\n if (!wallet.features['iota:signTransaction']) {\n throw new Error(\n `Provided wallet (${wallet.name}) does not support the signTransaction feature.`,\n );\n }\n\n return wallet.features['iota:signTransaction'].signTransaction(input);\n}\n"],
5
+ "mappings": "AA6BA,eAAsB,0BAClB,QACA,OACF;AACE,MAAI,CAAC,OAAO,SAAS,gCAAgC,GAAG;AACpD,UAAM,IAAI;AAAA,MACN,oBAAoB,OAAO,IAAI;AAAA,IACnC;AAAA,EACJ;AAEA,SAAO,OAAO,SAAS,gCAAgC,EAAE,0BAA0B,KAAK;AAC5F;AAEA,eAAsB,gBAClB,QACA,OACF;AACE,MAAI,CAAC,OAAO,SAAS,sBAAsB,GAAG;AAC1C,UAAM,IAAI;AAAA,MACN,oBAAoB,OAAO,IAAI;AAAA,IACnC;AAAA,EACJ;AAEA,SAAO,OAAO,SAAS,sBAAsB,EAAE,gBAAgB,KAAK;AACxE;",
6
6
  "names": []
7
7
  }