@ledgerhq/device-signer-kit-solana 1.2.0 → 1.4.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/README.md +110 -24
- package/lib/cjs/api/SignerSolana.js +1 -1
- package/lib/cjs/api/SignerSolana.js.map +1 -1
- package/lib/cjs/api/SolanaTools.js +1 -1
- package/lib/cjs/api/SolanaTools.js.map +1 -1
- package/lib/cjs/api/app-binder/SignMessageDeviceActionTypes.js.map +1 -1
- package/lib/cjs/api/app-binder/SignTransactionDeviceActionTypes.js.map +1 -1
- package/lib/cjs/api/index.js +1 -1
- package/lib/cjs/api/index.js.map +1 -1
- package/lib/cjs/api/model/SolanaTransactionOptionalConfig.js +2 -0
- package/lib/cjs/api/model/SolanaTransactionOptionalConfig.js.map +7 -0
- package/lib/cjs/api/model/TransactionResolutionContext.js +2 -0
- package/lib/cjs/api/model/TransactionResolutionContext.js.map +7 -0
- package/lib/cjs/internal/DefaultSignerSolana.js +1 -1
- package/lib/cjs/internal/DefaultSignerSolana.js.map +3 -3
- package/lib/cjs/internal/app-binder/SolanaAppBinder.js +1 -1
- package/lib/cjs/internal/app-binder/SolanaAppBinder.js.map +2 -2
- package/lib/cjs/internal/app-binder/SolanaAppBinder.test.js +1 -1
- package/lib/cjs/internal/app-binder/SolanaAppBinder.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/command/GetPubKeyCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/GetPubKeyCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignOffChainMessageCommand.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignOffChainMessageCommand.js.map +3 -3
- package/lib/cjs/internal/app-binder/command/SignOffChainMessageCommand.test.js +1 -1
- package/lib/cjs/internal/app-binder/command/SignOffChainMessageCommand.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.js.map +2 -2
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.test.js +1 -1
- package/lib/cjs/internal/app-binder/device-action/SignTransactionDeviceAction.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/services/GenerateSolanaTransaction.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/services/TransactionInspector.js +1 -3
- package/lib/cjs/internal/app-binder/services/TransactionInspector.js.map +3 -3
- package/lib/cjs/internal/app-binder/services/TransactionInspector.test.js +1 -1
- package/lib/cjs/internal/app-binder/services/TransactionInspector.test.js.map +3 -3
- package/lib/cjs/internal/app-binder/services/bs58Encoder.js +2 -0
- package/lib/cjs/internal/app-binder/services/bs58Encoder.js.map +7 -0
- package/lib/cjs/internal/app-binder/services/utils/transactionDecoders.js +2 -0
- package/lib/cjs/internal/app-binder/services/utils/transactionDecoders.js.map +7 -0
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.js.map +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/cjs/internal/app-binder/task/BuildTransactionContextTask.test.js.map +2 -2
- package/lib/cjs/internal/app-binder/task/SendSignMessageTask.js +1 -1
- package/lib/cjs/internal/app-binder/task/SendSignMessageTask.js.map +3 -3
- package/lib/cjs/internal/app-binder/task/SendSignMessageTask.test.js +3 -1
- package/lib/cjs/internal/app-binder/task/SendSignMessageTask.test.js.map +3 -3
- package/lib/cjs/internal/use-cases/transaction/SignTransactionUseCase.js +1 -1
- package/lib/cjs/internal/use-cases/transaction/SignTransactionUseCase.js.map +3 -3
- package/lib/cjs/internal/use-cases/transaction/SignTransactionUseCase.test.js +1 -1
- package/lib/cjs/internal/use-cases/transaction/SignTransactionUseCase.test.js.map +2 -2
- package/lib/cjs/package.json +2 -2
- package/lib/esm/api/index.js +1 -1
- package/lib/esm/api/index.js.map +1 -1
- package/lib/esm/api/model/SolanaTransactionOptionalConfig.js +1 -0
- package/lib/esm/api/model/TransactionResolutionContext.js +1 -0
- package/lib/esm/api/model/TransactionResolutionContext.js.map +7 -0
- package/lib/esm/internal/DefaultSignerSolana.js +1 -1
- package/lib/esm/internal/DefaultSignerSolana.js.map +3 -3
- package/lib/esm/internal/app-binder/SolanaAppBinder.js +1 -1
- package/lib/esm/internal/app-binder/SolanaAppBinder.js.map +2 -2
- package/lib/esm/internal/app-binder/SolanaAppBinder.test.js +1 -1
- package/lib/esm/internal/app-binder/SolanaAppBinder.test.js.map +2 -2
- package/lib/esm/internal/app-binder/command/GetPubKeyCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/GetPubKeyCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignOffChainMessageCommand.js +1 -1
- package/lib/esm/internal/app-binder/command/SignOffChainMessageCommand.js.map +3 -3
- package/lib/esm/internal/app-binder/command/SignOffChainMessageCommand.test.js +1 -1
- package/lib/esm/internal/app-binder/command/SignOffChainMessageCommand.test.js.map +3 -3
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.js.map +2 -2
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.test.js +1 -1
- package/lib/esm/internal/app-binder/device-action/SignTransactionDeviceAction.test.js.map +2 -2
- package/lib/esm/internal/app-binder/services/GenerateSolanaTransaction.test.js.map +3 -3
- package/lib/esm/internal/app-binder/services/TransactionInspector.js +1 -3
- package/lib/esm/internal/app-binder/services/TransactionInspector.js.map +3 -3
- package/lib/esm/internal/app-binder/services/TransactionInspector.test.js +1 -1
- package/lib/esm/internal/app-binder/services/TransactionInspector.test.js.map +3 -3
- package/lib/esm/internal/app-binder/services/bs58Encoder.js +2 -0
- package/lib/esm/internal/app-binder/services/bs58Encoder.js.map +7 -0
- package/lib/esm/internal/app-binder/services/utils/transactionDecoders.js +2 -0
- package/lib/esm/internal/app-binder/services/utils/transactionDecoders.js.map +7 -0
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.js.map +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js +1 -1
- package/lib/esm/internal/app-binder/task/BuildTransactionContextTask.test.js.map +2 -2
- package/lib/esm/internal/app-binder/task/SendSignMessageTask.js +1 -1
- package/lib/esm/internal/app-binder/task/SendSignMessageTask.js.map +3 -3
- package/lib/esm/internal/app-binder/task/SendSignMessageTask.test.js +3 -1
- package/lib/esm/internal/app-binder/task/SendSignMessageTask.test.js.map +3 -3
- package/lib/esm/internal/use-cases/transaction/SignTransactionUseCase.js +1 -1
- package/lib/esm/internal/use-cases/transaction/SignTransactionUseCase.js.map +3 -3
- package/lib/esm/internal/use-cases/transaction/SignTransactionUseCase.test.js +1 -1
- package/lib/esm/internal/use-cases/transaction/SignTransactionUseCase.test.js.map +2 -2
- package/lib/esm/package.json +2 -2
- package/lib/types/api/SignerSolana.d.ts +2 -2
- package/lib/types/api/SignerSolana.d.ts.map +1 -1
- package/lib/types/api/SolanaTools.d.ts +1 -2
- package/lib/types/api/SolanaTools.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignMessageDeviceActionTypes.d.ts +3 -2
- package/lib/types/api/app-binder/SignMessageDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts +2 -1
- package/lib/types/api/app-binder/SignTransactionDeviceActionTypes.d.ts.map +1 -1
- package/lib/types/api/index.d.ts +1 -1
- package/lib/types/api/index.d.ts.map +1 -1
- package/lib/types/api/model/SolanaTransactionOptionalConfig.d.ts +7 -0
- package/lib/types/api/model/SolanaTransactionOptionalConfig.d.ts.map +1 -0
- package/lib/types/api/model/{TransactionOptions.d.ts → TransactionResolutionContext.d.ts} +2 -2
- package/lib/types/api/model/TransactionResolutionContext.d.ts.map +1 -0
- package/lib/types/internal/DefaultSignerSolana.d.ts +290 -1
- package/lib/types/internal/DefaultSignerSolana.d.ts.map +1 -1
- package/lib/types/internal/app-binder/SolanaAppBinder.d.ts +2 -1
- package/lib/types/internal/app-binder/SolanaAppBinder.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/GetPubKeyCommand.d.ts +3 -1
- package/lib/types/internal/app-binder/command/GetPubKeyCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/command/SignOffChainMessageCommand.d.ts +13 -9
- package/lib/types/internal/app-binder/command/SignOffChainMessageCommand.d.ts.map +1 -1
- package/lib/types/internal/app-binder/device-action/SignTransactionDeviceAction.d.ts +3 -0
- package/lib/types/internal/app-binder/device-action/SignTransactionDeviceAction.d.ts.map +1 -1
- package/lib/types/internal/app-binder/services/TransactionInspector.d.ts +30 -5
- package/lib/types/internal/app-binder/services/TransactionInspector.d.ts.map +1 -1
- package/lib/types/internal/app-binder/services/bs58Encoder.d.ts +9 -0
- package/lib/types/internal/app-binder/services/bs58Encoder.d.ts.map +1 -0
- package/lib/types/internal/app-binder/services/utils/transactionDecoders.d.ts +14 -0
- package/lib/types/internal/app-binder/services/utils/transactionDecoders.d.ts.map +1 -0
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts +2 -2
- package/lib/types/internal/app-binder/task/BuildTransactionContextTask.d.ts.map +1 -1
- package/lib/types/internal/app-binder/task/SendSignMessageTask.d.ts +22 -6
- package/lib/types/internal/app-binder/task/SendSignMessageTask.d.ts.map +1 -1
- package/lib/types/internal/use-cases/transaction/SignTransactionUseCase.d.ts +2 -3
- package/lib/types/internal/use-cases/transaction/SignTransactionUseCase.d.ts.map +1 -1
- package/lib/types/tsconfig.prod.tsbuildinfo +1 -1
- package/package.json +7 -7
- package/lib/cjs/api/model/TransactionOptions.js +0 -2
- package/lib/cjs/api/model/TransactionOptions.js.map +0 -7
- package/lib/esm/api/model/TransactionOptions.js +0 -1
- package/lib/types/api/model/TransactionOptions.d.ts.map +0 -1
- /package/lib/esm/api/model/{TransactionOptions.js.map → SolanaTransactionOptionalConfig.js.map} +0 -0
package/README.md
CHANGED
|
@@ -93,53 +93,139 @@ type GetAddressCommandResponse = {
|
|
|
93
93
|
|
|
94
94
|
### Use Case 2: Sign Transaction
|
|
95
95
|
|
|
96
|
-
|
|
96
|
+
Securely sign a Solana or SPL transaction using **clear signing** on Ledger devices.
|
|
97
97
|
|
|
98
|
-
```
|
|
98
|
+
```ts
|
|
99
99
|
const { observable, cancel } = signerSolana.signTransaction(
|
|
100
100
|
derivationPath,
|
|
101
101
|
transaction,
|
|
102
|
-
|
|
102
|
+
transactionOptions,
|
|
103
103
|
);
|
|
104
104
|
```
|
|
105
105
|
|
|
106
|
-
|
|
106
|
+
---
|
|
107
107
|
|
|
108
|
-
|
|
108
|
+
### Parameters
|
|
109
109
|
|
|
110
|
-
|
|
111
|
-
- **Type:** `string` (e.g., `"44'/501'/0'"`)
|
|
112
|
-
- The derivation path used in the transaction. See [here](https://www.ledger.com/blog/understanding-crypto-addresses-and-derivation-paths) for more information.
|
|
110
|
+
**Required**
|
|
113
111
|
|
|
114
|
-
- `
|
|
112
|
+
- **derivationPath** `string`
|
|
113
|
+
The derivation path used in the transaction.
|
|
114
|
+
See [Ledger’s guide](https://www.ledger.com/blog/understanding-crypto-addresses-and-derivation-paths) for more information.
|
|
115
115
|
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
- The transaction object that needs to be signed.
|
|
116
|
+
- **transaction** `Uint8Array`
|
|
117
|
+
The serialized transaction to sign.
|
|
119
118
|
|
|
120
|
-
|
|
119
|
+
**Optional**
|
|
121
120
|
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
- No option defined yet, but will be used for clear signing in a near future.
|
|
121
|
+
- **transactionOptions** `SolanaTransactionOptionalConfig`
|
|
122
|
+
Provides additional context for transaction signing.
|
|
125
123
|
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
```
|
|
124
|
+
- **transactionResolutionContext** `object`
|
|
125
|
+
Lets you explicitly pass `tokenAddress` and ATA details, bypassing extraction from the transaction itself.
|
|
129
126
|
|
|
130
|
-
|
|
127
|
+
- **tokenAddress** `string`
|
|
128
|
+
SPL token address being transferred.
|
|
131
129
|
|
|
132
|
-
- `
|
|
130
|
+
- **createATA** `object`
|
|
131
|
+
Information about creating an associated token account (ATA).
|
|
133
132
|
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
- **address** `string` – Address (owner) of the ATA.
|
|
134
|
+
- **mintAddress** `string` – Mint address of the ATA.
|
|
135
|
+
|
|
136
|
+
- **solanaRPCURL** `string`
|
|
137
|
+
RPC endpoint to use if `transactionResolutionContext` is not provided
|
|
138
|
+
and parsing requires network lookups.
|
|
139
|
+
In browser environments, use a CORS-enabled RPC URL.
|
|
140
|
+
Defaults to: `"https://api.mainnet-beta.solana.com/"`.
|
|
141
|
+
|
|
142
|
+
---
|
|
143
|
+
|
|
144
|
+
### Returns
|
|
145
|
+
|
|
146
|
+
- `observable` That emits DeviceActionState updates, including the following details:
|
|
147
|
+
|
|
148
|
+
```ts
|
|
149
|
+
type SolanaSignature = {
|
|
150
|
+
signature: Uint8Array; // Signed transaction bytes
|
|
151
|
+
};
|
|
136
152
|
```
|
|
137
153
|
|
|
138
154
|
- `cancel` A function to cancel the action on the Ledger device.
|
|
139
155
|
|
|
156
|
+
---
|
|
157
|
+
|
|
158
|
+
### Internal Flow
|
|
159
|
+
|
|
160
|
+
Under the hood, this method subscribes to an
|
|
161
|
+
`Observable<DeviceActionState<Uint8Array, SignTransactionDAError, IntermediateValue>>`.
|
|
162
|
+
|
|
163
|
+
#### DeviceActionState
|
|
164
|
+
|
|
165
|
+
Represents the lifecycle of a device action:
|
|
166
|
+
|
|
167
|
+
```ts
|
|
168
|
+
type DeviceActionState<Output, Error, IntermediateValue> =
|
|
169
|
+
| { status: DeviceActionStatus.NotStarted }
|
|
170
|
+
| { status: DeviceActionStatus.Pending; intermediateValue: IntermediateValue }
|
|
171
|
+
| { status: DeviceActionStatus.Stopped }
|
|
172
|
+
| { status: DeviceActionStatus.Completed; output: Output }
|
|
173
|
+
| { status: DeviceActionStatus.Error; error: Error };
|
|
174
|
+
|
|
175
|
+
enum DeviceActionStatus {
|
|
176
|
+
NotStarted = "not-started",
|
|
177
|
+
Pending = "pending",
|
|
178
|
+
Stopped = "stopped",
|
|
179
|
+
Completed = "completed",
|
|
180
|
+
Error = "error",
|
|
181
|
+
}
|
|
182
|
+
```
|
|
183
|
+
|
|
184
|
+
- **NotStarted** → Action hasn’t begun.
|
|
185
|
+
- **Pending** → Waiting for user confirmation on the device.
|
|
186
|
+
Includes an `intermediateValue` of type `IntermediateValue`.
|
|
187
|
+
- **Stopped** → Action was cancelled before completion.
|
|
188
|
+
- **Completed** → Provides the signed transaction bytes (`Uint8Array`).
|
|
189
|
+
- **Error** → The device or signing operation failed (`SignTransactionDAError`).
|
|
190
|
+
|
|
191
|
+
---
|
|
192
|
+
|
|
193
|
+
### Example
|
|
194
|
+
|
|
195
|
+
```ts
|
|
196
|
+
const { observable } = dmkSigner.signTransaction(
|
|
197
|
+
"m/44'/501'/0'/0'",
|
|
198
|
+
serializedTx,
|
|
199
|
+
{
|
|
200
|
+
transactionResolutionContext: resolution,
|
|
201
|
+
},
|
|
202
|
+
);
|
|
203
|
+
|
|
204
|
+
const subscription = observable.subscribe({
|
|
205
|
+
next: (state) => {
|
|
206
|
+
switch (state.status) {
|
|
207
|
+
case DeviceActionStatus.Pending:
|
|
208
|
+
console.log("Waiting for user action...", state.intermediateValue);
|
|
209
|
+
break;
|
|
210
|
+
case DeviceActionStatus.Completed:
|
|
211
|
+
console.log("Signature:", state.output);
|
|
212
|
+
break;
|
|
213
|
+
case DeviceActionStatus.Error:
|
|
214
|
+
console.error("Error:", state.error);
|
|
215
|
+
break;
|
|
216
|
+
}
|
|
217
|
+
},
|
|
218
|
+
error: (err) => console.error("Observable error:", err),
|
|
219
|
+
complete: () => console.log("Signing flow ended"),
|
|
220
|
+
});
|
|
221
|
+
|
|
222
|
+
// Later if needed:
|
|
223
|
+
// subscription.unsubscribe();
|
|
224
|
+
```
|
|
225
|
+
|
|
140
226
|
#### **Notes**
|
|
141
227
|
|
|
142
|
-
- Clear signing only supports simple instructions like a single `transfer` or combos like `createAccound + fundAccount` or `createAccount + transfer`. If you are receiving `6808` error from device, most likely the instructions are not supported and blind signing is required
|
|
228
|
+
- Clear signing only supports simple instructions like a single `transfer` or combos like `createAccound + fundAccount` or `createAccount + transfer`. If you are receiving `6808` error from device, most likely the instructions are not supported and blind signing is required.
|
|
143
229
|
|
|
144
230
|
---
|
|
145
231
|
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var a=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var p=Object.prototype.hasOwnProperty;var g=(n,t,r,i)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of s(t))!p.call(n,e)&&e!==r&&o(n,e,{get:()=>t[e],enumerable:!(i=a(t,e))||i.enumerable});return n};var m=n=>g(o({},"__esModule",{value:!0}),n);var y={};module.exports=m(y);
|
|
2
2
|
//# sourceMappingURL=SignerSolana.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/SignerSolana.ts"],
|
|
4
|
-
"sourcesContent": ["import { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigurationDAReturnType } from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport { type SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOption\";\nimport { type MessageOptions } from \"@api/model/MessageOptions\";\nimport { type Transaction } from \"@api/model/Transaction\";\nimport { type
|
|
4
|
+
"sourcesContent": ["import { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigurationDAReturnType } from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport { type SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOption\";\nimport { type MessageOptions } from \"@api/model/MessageOptions\";\nimport { type Transaction } from \"@api/model/Transaction\";\n\nimport { type SolanaTransactionOptionalConfig } from \"./model/SolanaTransactionOptionalConfig\";\n\nexport interface SignerSolana {\n signTransaction: (\n derivationPath: string,\n transaction: Transaction,\n solanaTransactionOptionalConfig?: SolanaTransactionOptionalConfig,\n ) => SignTransactionDAReturnType;\n\n signMessage: (\n derivationPath: string,\n message: string,\n options?: MessageOptions,\n ) => SignMessageDAReturnType;\n\n getAddress: (\n derivationPath: string,\n options?: AddressOptions,\n ) => GetAddressDAReturnType;\n\n getAppConfiguration: () => GetAppConfigurationDAReturnType;\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["SignerSolana_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=Object.defineProperty;var
|
|
1
|
+
"use strict";var o=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var a=Object.getOwnPropertyNames;var s=Object.prototype.hasOwnProperty;var A=(t,e,p,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of a(e))!s.call(t,r)&&r!==p&&o(t,r,{get:()=>e[r],enumerable:!(n=i(e,r))||n.enumerable});return t};var d=t=>A(o({},"__esModule",{value:!0}),t);var y={};module.exports=d(y);
|
|
2
2
|
//# sourceMappingURL=SolanaTools.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/SolanaTools.ts"],
|
|
4
|
-
"sourcesContent": ["import { type GenerateTransactionDAReturnType } from \"@api/app-binder/GenerateTransactionDeviceActionTypes\";\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigurationDAReturnType } from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOption\";\
|
|
4
|
+
"sourcesContent": ["import { type GenerateTransactionDAReturnType } from \"@api/app-binder/GenerateTransactionDeviceActionTypes\";\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigurationDAReturnType } from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOption\";\n\nexport interface SolanaTools {\n generateTransaction: (\n derivationPath: string,\n ) => GenerateTransactionDAReturnType;\n\n getAddress: (\n derivationPath: string,\n options?: AddressOptions,\n ) => GetAddressDAReturnType;\n\n getAppConfiguration: () => GetAppConfigurationDAReturnType;\n}\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["SolanaTools_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/app-binder/SignMessageDeviceActionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import {\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type SendCommandInAppDAError,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type
|
|
4
|
+
"sourcesContent": ["import {\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type SendCommandInAppDAError,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type SolanaAppErrorCodes } from \"@internal/app-binder/command/utils/SolanaApplicationErrors\";\n\nexport type SignMessageDAOutput = {\n signature: string;\n};\n\nexport type SignMessageDAError =\n | OpenAppDAError\n | SendCommandInAppDAError<SolanaAppErrorCodes>;\n\ntype SignMessageDARequiredInteraction =\n | OpenAppDARequiredInteraction\n | UserInteractionRequired.SignPersonalMessage;\n\nexport type SignMessageDAIntermediateValue = {\n requiredUserInteraction: SignMessageDARequiredInteraction;\n};\n\nexport type SignMessageDAReturnType = ExecuteDeviceActionReturnType<\n SignMessageDAOutput,\n SignMessageDAError,\n SignMessageDAIntermediateValue\n>;\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["SignMessageDeviceActionTypes_exports", "__toCommonJS"]
|
|
7
7
|
}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/api/app-binder/SignTransactionDeviceActionTypes.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport { type SolanaTransactionContextResultSuccess } from \"@ledgerhq/context-module/src/solana/domain/solanaContextTypes.js\";\nimport {\n type DeviceActionState,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type SendCommandInAppDAError,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type AppConfiguration } from \"@api/model/AppConfiguration\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { type Transaction } from \"@api/model/Transaction\";\nimport { type SolanaAppErrorCodes } from \"@internal/app-binder/command/utils/SolanaApplicationErrors\";\nimport { type TxInspectorResult } from \"@internal/app-binder/services/TransactionInspector\";\n\nexport type SignTransactionDAOutput = Signature;\n\nexport type SignTransactionDAInput = {\n readonly derivationPath: string;\n readonly transaction: Transaction;\n readonly
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport { type SolanaTransactionContextResultSuccess } from \"@ledgerhq/context-module/src/solana/domain/solanaContextTypes.js\";\nimport {\n type DeviceActionState,\n type ExecuteDeviceActionReturnType,\n type OpenAppDAError,\n type OpenAppDARequiredInteraction,\n type SendCommandInAppDAError,\n type UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\n\nimport { type AppConfiguration } from \"@api/model/AppConfiguration\";\nimport { type Signature } from \"@api/model/Signature\";\nimport { type SolanaTransactionOptionalConfig } from \"@api/model/SolanaTransactionOptionalConfig\";\nimport { type Transaction } from \"@api/model/Transaction\";\nimport { type SolanaAppErrorCodes } from \"@internal/app-binder/command/utils/SolanaApplicationErrors\";\nimport { type TxInspectorResult } from \"@internal/app-binder/services/TransactionInspector\";\n\nexport type SignTransactionDAOutput = Signature;\n\nexport type SignTransactionDAInput = {\n readonly derivationPath: string;\n readonly transaction: Transaction;\n readonly transactionOptions?: SolanaTransactionOptionalConfig;\n readonly contextModule: ContextModule;\n};\n\nexport type SignTransactionDAError =\n | OpenAppDAError\n | SendCommandInAppDAError<SolanaAppErrorCodes>;\n\ntype SignTransactionDARequiredInteraction =\n | UserInteractionRequired\n | OpenAppDARequiredInteraction;\n\nexport type SignTransactionDAIntermediateValue = {\n requiredUserInteraction: SignTransactionDARequiredInteraction;\n};\n\nexport type SignTransactionDAState = DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n>;\n\nexport type SignTransactionDAInternalState = {\n readonly error: SignTransactionDAError | null;\n readonly signature: Signature | null;\n readonly appConfig: AppConfiguration | null;\n readonly solanaTransactionContext: SolanaTransactionContextResultSuccess | null;\n readonly inspectorResult: TxInspectorResult | null;\n};\n\nexport type SignTransactionDAReturnType = ExecuteDeviceActionReturnType<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n>;\n"],
|
|
5
5
|
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
6
|
"names": ["SignTransactionDeviceActionTypes_exports", "__toCommonJS"]
|
|
7
7
|
}
|
package/lib/cjs/api/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var n=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var A=Object.getOwnPropertyNames;var u=Object.prototype.hasOwnProperty;var d=(r,e)=>{for(var t in e)n(r,t,{get:e[t],enumerable:!0})},T=(r,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let a of A(e))!u.call(r,a)&&a!==t&&n(r,a,{get:()=>e[a],enumerable:!(o=s(e,a))||o.enumerable});return r};var c=r=>T(n({},"__esModule",{value:!0}),r);var g={};d(g,{SignerSolanaBuilder:()=>i.SignerSolanaBuilder,SolanaToolsBuilder:()=>p.SolanaToolsBuilder});module.exports=c(g);var i=require("./SignerSolanaBuilder"),p=require("./SolanaToolsBuilder");0&&(module.exports={SignerSolanaBuilder,SolanaToolsBuilder});
|
|
2
2
|
//# sourceMappingURL=index.js.map
|
package/lib/cjs/api/index.js.map
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/api/index.ts"],
|
|
4
|
-
"sourcesContent": ["export type {\n GenerateTransactionDAError,\n GenerateTransactionDAIntermediateValue,\n GenerateTransactionDAOutput,\n GenerateTransactionDAReturnType,\n} from \"@api/app-binder/GenerateTransactionDeviceActionTypes\";\nexport type {\n GetAddressDAError,\n GetAddressDAIntermediateValue,\n GetAddressDAOutput,\n GetAddressDAReturnType,\n} from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport type {\n GetAppConfigurationDAError,\n GetAppConfigurationDAIntermediateValue,\n GetAppConfigurationDAOutput,\n} from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nexport type {\n SignMessageDAError,\n SignMessageDAIntermediateValue,\n SignMessageDAOutput,\n} from \"@api/app-binder/SignMessageDeviceActionTypes\";\nexport type {\n SignTransactionDAError,\n SignTransactionDAIntermediateValue,\n SignTransactionDAOutput,\n SignTransactionDAReturnType,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nexport type { Signature } from \"@api/model/Signature\";\nexport type {
|
|
4
|
+
"sourcesContent": ["export type {\n GenerateTransactionDAError,\n GenerateTransactionDAIntermediateValue,\n GenerateTransactionDAOutput,\n GenerateTransactionDAReturnType,\n} from \"@api/app-binder/GenerateTransactionDeviceActionTypes\";\nexport type {\n GetAddressDAError,\n GetAddressDAIntermediateValue,\n GetAddressDAOutput,\n GetAddressDAReturnType,\n} from \"@api/app-binder/GetAddressDeviceActionTypes\";\nexport type {\n GetAppConfigurationDAError,\n GetAppConfigurationDAIntermediateValue,\n GetAppConfigurationDAOutput,\n} from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nexport type {\n SignMessageDAError,\n SignMessageDAIntermediateValue,\n SignMessageDAOutput,\n} from \"@api/app-binder/SignMessageDeviceActionTypes\";\nexport type {\n SignTransactionDAError,\n SignTransactionDAIntermediateValue,\n SignTransactionDAOutput,\n SignTransactionDAReturnType,\n} from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nexport type { Signature } from \"@api/model/Signature\";\nexport type { SolanaTransactionOptionalConfig } from \"@api/model/SolanaTransactionOptionalConfig\";\nexport type { Transaction } from \"@api/model/Transaction\";\nexport type { SignerSolana } from \"@api/SignerSolana\";\nexport { SignerSolanaBuilder } from \"@api/SignerSolanaBuilder\";\nexport type { SolanaTools } from \"@api/SolanaTools\";\nexport { SolanaToolsBuilder } from \"@api/SolanaToolsBuilder\";\n"],
|
|
5
5
|
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,4GAAAE,EAAAF,GAgCA,IAAAG,EAAoC,oCAEpCC,EAAmC",
|
|
6
6
|
"names": ["api_exports", "__export", "__toCommonJS", "import_SignerSolanaBuilder", "import_SolanaToolsBuilder"]
|
|
7
7
|
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var i=Object.defineProperty;var s=Object.getOwnPropertyDescriptor;var p=Object.getOwnPropertyNames;var r=Object.prototype.hasOwnProperty;var l=(n,o,e,a)=>{if(o&&typeof o=="object"||typeof o=="function")for(let t of p(o))!r.call(n,t)&&t!==e&&i(n,t,{get:()=>o[t],enumerable:!(a=s(o,t))||a.enumerable});return n};var C=n=>l(i({},"__esModule",{value:!0}),n);var R={};module.exports=C(R);
|
|
2
|
+
//# sourceMappingURL=SolanaTransactionOptionalConfig.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/model/SolanaTransactionOptionalConfig.ts"],
|
|
4
|
+
"sourcesContent": ["import { type TransactionResolutionContext } from \"./TransactionResolutionContext\";\n\nexport type SolanaTransactionOptionalConfig = {\n transactionResolutionContext?: TransactionResolutionContext;\n solanaRPCURL?: string;\n skipOpenApp?: boolean;\n};\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["SolanaTransactionOptionalConfig_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
"use strict";var r=Object.defineProperty;var i=Object.getOwnPropertyDescriptor;var o=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var A=(s,t,d,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let e of o(t))!a.call(s,e)&&e!==d&&r(s,e,{get:()=>t[e],enumerable:!(n=i(t,e))||n.enumerable});return s};var g=s=>A(r({},"__esModule",{value:!0}),s);var c={};module.exports=g(c);
|
|
2
|
+
//# sourceMappingURL=TransactionResolutionContext.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../../../src/api/model/TransactionResolutionContext.ts"],
|
|
4
|
+
"sourcesContent": ["export type TransactionResolutionContext = {\n tokenAddress?: string;\n createATA?: {\n address: string;\n mintAddress: string;\n };\n};\n"],
|
|
5
|
+
"mappings": "+WAAA,IAAAA,EAAA,kBAAAC,EAAAD",
|
|
6
|
+
"names": ["TransactionResolutionContext_exports", "__toCommonJS"]
|
|
7
|
+
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var u=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},c=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of g(e))!m.call(n,s)&&s!==t&&i(n,s,{get:()=>e[s],enumerable:!(r=p(e,s))||r.enumerable});return n};var f=n=>c(i({},"__esModule",{value:!0}),n);var
|
|
1
|
+
"use strict";var i=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var g=Object.getOwnPropertyNames;var m=Object.prototype.hasOwnProperty;var u=(n,e)=>{for(var t in e)i(n,t,{get:e[t],enumerable:!0})},c=(n,e,t,r)=>{if(e&&typeof e=="object"||typeof e=="function")for(let s of g(e))!m.call(n,s)&&s!==t&&i(n,s,{get:()=>e[s],enumerable:!(r=p(e,s))||r.enumerable});return n};var f=n=>c(i({},"__esModule",{value:!0}),n);var y={};u(y,{DefaultSignerSolana:()=>C});module.exports=f(y);var o=require("./use-cases/di/useCasesTypes"),a=require("./di");class C{_container;constructor({dmk:e,sessionId:t,contextModule:r}){this._container=(0,a.makeContainer)({dmk:e,sessionId:t,contextModule:r})}signTransaction(e,t,r){return this._container.get(o.useCasesTypes.SignTransactionUseCase).execute(e,t,r)}signMessage(e,t,r){return this._container.get(o.useCasesTypes.SignMessageUseCase).execute(e,t,r)}getAddress(e,t){return this._container.get(o.useCasesTypes.GetAddressUseCase).execute(e,t)}getAppConfiguration(){return this._container.get(o.useCasesTypes.GetAppConfigurationUseCase).execute()}}0&&(module.exports={DefaultSignerSolana});
|
|
2
2
|
//# sourceMappingURL=DefaultSignerSolana.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../src/internal/DefaultSignerSolana.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Container } from \"inversify\";\n\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigurationDAReturnType } from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport { type SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOption\";\nimport { type MessageOptions } from \"@api/model/MessageOptions\";\nimport { type Transaction } from \"@api/model/Transaction\";\nimport { type SignerSolana } from \"@api/SignerSolana\";\n\nimport { type GetAddressUseCase } from \"./use-cases/address/GetAddressUseCase\";\nimport { type GetAppConfigurationUseCase } from \"./use-cases/app-configuration/GetAppConfigurationUseCase\";\nimport { useCasesTypes } from \"./use-cases/di/useCasesTypes\";\nimport { type SignMessageUseCase } from \"./use-cases/message/SignMessageUseCase\";\nimport { type SignTransactionUseCase } from \"./use-cases/transaction/SignTransactionUseCase\";\nimport { makeContainer } from \"./di\";\n\nexport type DefaultSignerSolanaConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n contextModule: ContextModule;\n};\n\nexport class DefaultSignerSolana implements SignerSolana {\n private _container: Container;\n\n constructor({\n dmk,\n sessionId,\n contextModule,\n }: DefaultSignerSolanaConstructorArgs) {\n this._container = makeContainer({ dmk, sessionId, contextModule });\n }\n\n signTransaction(\n derivationPath: string,\n transaction: Transaction,\n ): SignTransactionDAReturnType {\n return this._container\n .get<SignTransactionUseCase>(useCasesTypes.SignTransactionUseCase)\n .execute(derivationPath, transaction);\n }\n\n signMessage(\n derivationPath: string,\n message: string,\n options?: MessageOptions,\n ): SignMessageDAReturnType {\n return this._container\n .get<SignMessageUseCase>(useCasesTypes.SignMessageUseCase)\n .execute(derivationPath, message, options);\n }\n\n getAddress(\n derivationPath: string,\n options?: AddressOptions,\n ): GetAddressDAReturnType {\n return this._container\n .get<GetAddressUseCase>(useCasesTypes.GetAddressUseCase)\n .execute(derivationPath, options);\n }\n\n getAppConfiguration(): GetAppConfigurationDAReturnType {\n return this._container\n .get<GetAppConfigurationUseCase>(useCasesTypes.GetAppConfigurationUseCase)\n .execute();\n }\n}\n"],
|
|
5
|
-
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,
|
|
6
|
-
"names": ["DefaultSignerSolana_exports", "__export", "DefaultSignerSolana", "__toCommonJS", "import_useCasesTypes", "import_di", "dmk", "sessionId", "contextModule", "derivationPath", "transaction", "message", "options"]
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type DeviceManagementKit,\n type DeviceSessionId,\n} from \"@ledgerhq/device-management-kit\";\nimport { type Container } from \"inversify\";\n\nimport { type GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { type GetAppConfigurationDAReturnType } from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport { type SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { type SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { type AddressOptions } from \"@api/model/AddressOption\";\nimport { type MessageOptions } from \"@api/model/MessageOptions\";\nimport { type SolanaTransactionOptionalConfig } from \"@api/model/SolanaTransactionOptionalConfig\";\nimport { type Transaction } from \"@api/model/Transaction\";\nimport { type SignerSolana } from \"@api/SignerSolana\";\n\nimport { type GetAddressUseCase } from \"./use-cases/address/GetAddressUseCase\";\nimport { type GetAppConfigurationUseCase } from \"./use-cases/app-configuration/GetAppConfigurationUseCase\";\nimport { useCasesTypes } from \"./use-cases/di/useCasesTypes\";\nimport { type SignMessageUseCase } from \"./use-cases/message/SignMessageUseCase\";\nimport { type SignTransactionUseCase } from \"./use-cases/transaction/SignTransactionUseCase\";\nimport { makeContainer } from \"./di\";\n\nexport type DefaultSignerSolanaConstructorArgs = {\n dmk: DeviceManagementKit;\n sessionId: DeviceSessionId;\n contextModule: ContextModule;\n};\n\nexport class DefaultSignerSolana implements SignerSolana {\n private _container: Container;\n\n constructor({\n dmk,\n sessionId,\n contextModule,\n }: DefaultSignerSolanaConstructorArgs) {\n this._container = makeContainer({ dmk, sessionId, contextModule });\n }\n\n /**\n * ## signTransaction\n * #### Securely sign a Solana or SPL transaction using **clear signing** on Ledger devices.\n * ---\n * ### Parameters\n *\n * **Required**\n * - **derivationPath** `string`\n * The derivation path used in the transaction.\n *\n * - **transaction** `Uint8Array`\n * The serialised transaction to sign.\n *\n * **Optional**\n * - **options** `SolanaTransactionOptionalConfig`\n * Provides additional context for transaction signing.\n *\n * - **transactionResolutionContext** `object`\n * Lets you explicitly pass `tokenAddress` and ATA details, bypassing extraction from the transaction itself.\n *\n * - **tokenAddress** `string`\n * SPL token address being transferred.\n *\n * - **createATA** `object`\n * Information about creating an associated token account (ATA).\n *\n * - **address** `string` \u2013 Address (owner) of the ATA.\n * - **mintAddress** `string` \u2013 Mint address of the ATA.\n *\n * - **solanaRPCURL** `string`\n * RPC endpoint to use if `transactionResolutionContext` is not provided\n * and parsing requires network lookups.\n * In browser environments, use a CORS-enabled RPC URL.\n * Defaults to: `\"https://api.mainnet-beta.solana.com/\"`.\n *\n * - **skipOpenApp** `boolean`\n * If `true`, skips opening the Solana app on the device.\n *\n * ---\n * ### Returns\n *\n * - `observable` That emits DeviceActionState updates\n * - `cancel` A function to cancel the action on the Ledger device.\n *\n * ---\n * ### Internal Flow\n *\n * Under the hood, this method subscribes to an\n * `Observable<DeviceActionState<Uint8Array, SignTransactionDAError, IntermediateValue>>`.\n *\n * #### DeviceActionState\n * Represents the lifecycle of a device action:\n *\n * ```ts\n * type DeviceActionState<Output, Error, IntermediateValue> =\n * | { status: DeviceActionStatus.NotStarted }\n * | { status: DeviceActionStatus.Pending; intermediateValue: IntermediateValue }\n * | { status: DeviceActionStatus.Stopped }\n * | { status: DeviceActionStatus.Completed; output: Output }\n * | { status: DeviceActionStatus.Error; error: Error };\n *\n * enum DeviceActionStatus {\n * NotStarted = \"not-started\",\n * Pending = \"pending\",\n * Stopped = \"stopped\",\n * Completed = \"completed\",\n * Error = \"error\"\n * }\n * ```\n *\n * - **NotStarted** \u2192 Action hasn\u2019t begun.\n * - **Pending** \u2192 Waiting for user confirmation on the device.\n * Includes an `intermediateValue` of type `IntermediateValue`.\n * - **Stopped** \u2192 Action was cancelled before completion.\n * - **Completed** \u2192 Provides the signed transaction bytes (`Uint8Array`).\n * - **Error** \u2192 The device or signing operation failed (`SignTransactionDAError`).\n *\n * ---\n * ### Example\n *\n * ```ts\n * const { observable } = signerSolana.signTransaction(\"m/44'/501'/0'/0'\", serializedTx, {\n * transactionResolutionContext: resolution,\n * });\n * observable.subscribe({\n * next: state => {\n * if (state.status === DeviceActionStatus.Pending) {\n * console.log(\"Waiting for user action...\", state.intermediateValue);\n * }\n * if (state.status === DeviceActionStatus.Completed) {\n * console.log(\"Signature:\", state.output);\n * }\n * },\n * error: err => console.error(\"Error:\", err),\n * });\n * ```\n */\n signTransaction(\n derivationPath: string,\n transaction: Transaction,\n solanaTransactionOptionalConfig?: SolanaTransactionOptionalConfig,\n ): SignTransactionDAReturnType {\n return this._container\n .get<SignTransactionUseCase>(useCasesTypes.SignTransactionUseCase)\n .execute(derivationPath, transaction, solanaTransactionOptionalConfig);\n }\n\n /**\n * ## signMessage\n * #### Securely sign an arbitrary message on Ledger devices.\n * ---\n * ### Parameters\n *\n * **Required**\n * - **derivationPath** `string`\n * The derivation path used for signing.\n *\n * - **message** `string (hex-encoded)`\n * The message to sign, provided as a hex string.\n *\n * **Optional**\n * - **options** `MessageOptions`\n * - **skipOpenApp** `boolean`\n * If `true`, skips opening the Solana app on the device.\n *\n * ---\n * ### Returns\n *\n * - `observable` That emits DeviceActionState updates\n * - `cancel` A function to cancel the action on the Ledger device.\n *\n * ---\n * ### Internal Flow\n *\n * Under the hood, this method subscribes to an\n * `Observable<DeviceActionState<Uint8Array, SignMessageDAError, IntermediateValue>>`.\n *\n * #### DeviceActionState\n * Represents the lifecycle of a device action:\n *\n * ```ts\n * type DeviceActionState<Output, Error, IntermediateValue> =\n * | { status: DeviceActionStatus.NotStarted }\n * | { status: DeviceActionStatus.Pending; intermediateValue: IntermediateValue }\n * | { status: DeviceActionStatus.Stopped }\n * | { status: DeviceActionStatus.Completed; output: Output }\n * | { status: DeviceActionStatus.Error; error: Error };\n *\n * enum DeviceActionStatus {\n * NotStarted = \"not-started\",\n * Pending = \"pending\",\n * Stopped = \"stopped\",\n * Completed = \"completed\",\n * Error = \"error\"\n * }\n * ```\n *\n * - **NotStarted** \u2192 Action hasn\u2019t begun.\n * - **Pending** \u2192 Waiting for user confirmation on the device.\n * Includes an `intermediateValue` of type `IntermediateValue`.\n * - **Stopped** \u2192 Action was cancelled before completion.\n * - **Completed** \u2192 Provides the signed message bytes (`Uint8Array`).\n * - **Error** \u2192 The device or signing operation failed (`SignMessageDAError`).\n *\n * ---\n * ### Example\n *\n * ```ts\n * const { observable } = signerSolana.signMessage(\n * \"m/44'/501'/0'/0'\",\n * \"48656c6c6f20576f726c64\" // hex string\n * );\n * observable.subscribe({\n * next: state => {\n * if (state.status === DeviceActionStatus.Pending) {\n * console.log(\"Waiting for user action...\", state.intermediateValue);\n * }\n * if (state.status === DeviceActionStatus.Completed) {\n * console.log(\"Signature:\", state.output);\n * }\n * },\n * error: err => console.error(\"Error:\", err),\n * });\n * ```\n */\n signMessage(\n derivationPath: string,\n message: string,\n options?: MessageOptions,\n ): SignMessageDAReturnType {\n return this._container\n .get<SignMessageUseCase>(useCasesTypes.SignMessageUseCase)\n .execute(derivationPath, message, options);\n }\n\n /**\n * ## getAddress\n * #### Retrieve a Solana address from Ledger devices.\n * ---\n * ### Parameters\n *\n * **Required**\n * - **derivationPath** `string`\n * The derivation path of the account to retrieve the address from.\n *\n * **Optional**\n * - **options** `AddressOptions`\n * - **checkOnDevice** `boolean`\n * If `true`, prompts the user to verify the address on the device.\n *\n * - **skipOpenApp** `boolean`\n * If `true`, skips opening the Solana app on the device.\n *\n * ---\n * ### Returns\n *\n * - `observable` That emits DeviceActionState updates\n * - `cancel` A function to cancel the action on the Ledger device.\n *\n * ---\n * ### Internal Flow\n *\n * Under the hood, this method subscribes to an\n * `Observable<DeviceActionState<string, GetAddressDAError, IntermediateValue>>`.\n *\n * #### DeviceActionState\n * Represents the lifecycle of a device action:\n *\n * ```ts\n * type DeviceActionState<Output, Error, IntermediateValue> =\n * | { status: DeviceActionStatus.NotStarted }\n * | { status: DeviceActionStatus.Pending; intermediateValue: IntermediateValue }\n * | { status: DeviceActionStatus.Stopped }\n * | { status: DeviceActionStatus.Completed; output: Output }\n * | { status: DeviceActionStatus.Error; error: Error };\n *\n * enum DeviceActionStatus {\n * NotStarted = \"not-started\",\n * Pending = \"pending\",\n * Stopped = \"stopped\",\n * Completed = \"completed\",\n * Error = \"error\"\n * }\n * ```\n *\n * - **NotStarted** \u2192 Action hasn\u2019t begun.\n * - **Pending** \u2192 Waiting for user confirmation on the device.\n * Includes an `intermediateValue` of type `IntermediateValue`.\n * - **Stopped** \u2192 Action was cancelled before completion.\n * - **Completed** \u2192 Provides the base58-encoded address string, decoded to `Uint8Array`.\n * - **Error** \u2192 The device or signing operation failed (`GetAddressDAError`).\n *\n */\n getAddress(\n derivationPath: string,\n options?: AddressOptions,\n ): GetAddressDAReturnType {\n return this._container\n .get<GetAddressUseCase>(useCasesTypes.GetAddressUseCase)\n .execute(derivationPath, options);\n }\n\n /**\n * ## getAppConfiguration\n * #### Retrieve the current Solana app configuration from a Ledger device.\n * ---\n * ### Parameters\n *\n * This method does not require any parameters.\n *\n * ---\n * ### Returns\n *\n * - `observable` That emits DeviceActionState updates\n * - `cancel` A function to cancel the action on the Ledger device.\n *\n * ---\n * ### Internal Flow\n *\n * Under the hood, this method subscribes to an\n * `Observable<DeviceActionState<GetAppConfigurationResult, Error, IntermediateValue>>`.\n *\n * #### DeviceActionState\n * Represents the lifecycle of a device action:\n *\n * ```ts\n * type DeviceActionState<Output, Error, IntermediateValue> =\n * | { status: DeviceActionStatus.NotStarted }\n * | { status: DeviceActionStatus.Pending; intermediateValue: IntermediateValue }\n * | { status: DeviceActionStatus.Stopped }\n * | { status: DeviceActionStatus.Completed; output: Output }\n * | { status: DeviceActionStatus.Error; error: Error };\n *\n * enum DeviceActionStatus {\n * NotStarted = \"not-started\",\n * Pending = \"pending\",\n * Stopped = \"stopped\",\n * Completed = \"completed\",\n * Error = \"error\"\n * }\n * ```\n *\n * - **NotStarted** \u2192 Action hasn\u2019t begun.\n * - **Pending** \u2192 Waiting for user confirmation on the device.\n * Includes an `intermediateValue` of type `IntermediateValue`.\n * - **Stopped** \u2192 Action was cancelled before completion.\n * - **Completed** \u2192 Provides the app configuration object.\n * - **Error** \u2192 The device or signing operation failed.\n *\n * ---\n * ### Example\n *\n * ```ts\n * const config = await signerSolana.getAppConfiguration();\n * console.log(config.version, config.flags);\n * ```\n */\n getAppConfiguration(): GetAppConfigurationDAReturnType {\n return this._container\n .get<GetAppConfigurationUseCase>(useCasesTypes.GetAppConfigurationUseCase)\n .execute();\n }\n}\n"],
|
|
5
|
+
"mappings": "yaAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,yBAAAE,IAAA,eAAAC,EAAAH,GAmBA,IAAAI,EAA8B,wCAG9BC,EAA8B,gBAQvB,MAAMH,CAA4C,CAC/C,WAER,YAAY,CACV,IAAAI,EACA,UAAAC,EACA,cAAAC,CACF,EAAuC,CACrC,KAAK,cAAa,iBAAc,CAAE,IAAAF,EAAK,UAAAC,EAAW,cAAAC,CAAc,CAAC,CACnE,CAmGA,gBACEC,EACAC,EACAC,EAC6B,CAC7B,OAAO,KAAK,WACT,IAA4B,gBAAc,sBAAsB,EAChE,QAAQF,EAAgBC,EAAaC,CAA+B,CACzE,CAgFA,YACEF,EACAG,EACAC,EACyB,CACzB,OAAO,KAAK,WACT,IAAwB,gBAAc,kBAAkB,EACxD,QAAQJ,EAAgBG,EAASC,CAAO,CAC7C,CA4DA,WACEJ,EACAI,EACwB,CACxB,OAAO,KAAK,WACT,IAAuB,gBAAc,iBAAiB,EACtD,QAAQJ,EAAgBI,CAAO,CACpC,CAyDA,qBAAuD,CACrD,OAAO,KAAK,WACT,IAAgC,gBAAc,0BAA0B,EACxE,QAAQ,CACb,CACF",
|
|
6
|
+
"names": ["DefaultSignerSolana_exports", "__export", "DefaultSignerSolana", "__toCommonJS", "import_useCasesTypes", "import_di", "dmk", "sessionId", "contextModule", "derivationPath", "transaction", "solanaTransactionOptionalConfig", "message", "options"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var p=Object.defineProperty;var A=Object.getOwnPropertyDescriptor;var h=Object.getOwnPropertyNames;var k=Object.prototype.hasOwnProperty;var I=(n,e)=>{for(var t in e)p(n,t,{get:e[t],enumerable:!0})},O=(n,e,t,o)=>{if(e&&typeof e=="object"||typeof e=="function")for(let i of h(e))!k.call(n,i)&&i!==t&&p(n,i,{get:()=>e[i],enumerable:!(o=A(e,i))||o.enumerable});return n};var x=n=>O(p({},"__esModule",{value:!0}),n),v=(n,e,t,o)=>{for(var i=o>1?void 0:o?A(e,t):e,m=n.length-1,u;m>=0;m--)(u=n[m])&&(i=(o?u(e,t,i):u(i))||i);return o&&i&&p(e,t,i),i},c=(n,e)=>(t,o)=>e(t,o,n);var y={};I(y,{SolanaAppBinder:()=>r});module.exports=x(y);var s=require("@ledgerhq/device-management-kit"),a=require("inversify"),g=require("../app-binder/task/SendSignMessageTask"),d=require("../externalTypes"),T=require("./command/GetAppConfigurationCommand"),l=require("./command/GetPubKeyCommand"),D=require("./device-action/GenerateTransactionDeviceAction"),f=require("./device-action/SignTransactionDeviceAction");let r=class{constructor(e,t,o){this.dmk=e;this.sessionId=t;this.contextModule=o}getAddress(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new s.SendCommandInAppDeviceAction({input:{command:new l.GetPubKeyCommand(e),appName:"Solana",requiredUserInteraction:e.checkOnDevice?s.UserInteractionRequired.VerifyAddress:s.UserInteractionRequired.None,skipOpenApp:e.skipOpenApp}})})}signTransaction(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new f.SignTransactionDeviceAction({input:{derivationPath:e.derivationPath,transaction:e.transaction,transactionOptions:e.solanaTransactionOptionalConfig,contextModule:this.contextModule}})})}generateTransaction(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new D.GenerateTransactionDeviceAction({input:{derivationPath:e.derivationPath,skipOpenApp:e.skipOpenApp,contextModule:this.contextModule}})})}signMessage(e){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new s.CallTaskInAppDeviceAction({input:{task:async t=>new g.SendSignMessageTask(t,{derivationPath:e.derivationPath,sendingData:new TextEncoder().encode(e.message)}).run(),appName:"Solana",requiredUserInteraction:s.UserInteractionRequired.SignPersonalMessage,skipOpenApp:e.skipOpenApp}})})}getAppConfiguration(){return this.dmk.executeDeviceAction({sessionId:this.sessionId,deviceAction:new s.SendCommandInAppDeviceAction({input:{command:new T.GetAppConfigurationCommand,appName:"Solana",requiredUserInteraction:s.UserInteractionRequired.None,skipOpenApp:!1}})})}};r=v([(0,a.injectable)(),c(0,(0,a.inject)(d.externalTypes.Dmk)),c(1,(0,a.inject)(d.externalTypes.SessionId)),c(2,(0,a.inject)(d.externalTypes.ContextModule))],r);0&&(module.exports={SolanaAppBinder});
|
|
2
2
|
//# sourceMappingURL=SolanaAppBinder.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/app-binder/SolanaAppBinder.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n CallTaskInAppDeviceAction,\n DeviceManagementKit,\n type DeviceSessionId,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { GenerateTransactionDAReturnType } from \"@api/app-binder/GenerateTransactionDeviceActionTypes\";\nimport { GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { GetAppConfigurationDAReturnType } from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport { SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { Transaction } from \"@api/model/Transaction\";\nimport { SendSignMessageTask } from \"@internal/app-binder/task/SendSignMessageTask\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\nimport { GetAppConfigurationCommand } from \"./command/GetAppConfigurationCommand\";\nimport { GetPubKeyCommand } from \"./command/GetPubKeyCommand\";\nimport { GenerateTransactionDeviceAction } from \"./device-action/GenerateTransactionDeviceAction\";\nimport { SignTransactionDeviceAction } from \"./device-action/SignTransactionDeviceAction\";\n\n@injectable()\nexport class SolanaAppBinder {\n constructor(\n @inject(externalTypes.Dmk) private dmk: DeviceManagementKit,\n @inject(externalTypes.SessionId) private sessionId: DeviceSessionId,\n @inject(externalTypes.ContextModule) private contextModule: ContextModule,\n ) {}\n\n getAddress(args: {\n derivationPath: string;\n checkOnDevice: boolean;\n skipOpenApp: boolean;\n }): GetAddressDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetPubKeyCommand(args),\n appName: \"Solana\",\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n signTransaction(args: {\n derivationPath: string;\n transaction: Transaction;\n
|
|
5
|
-
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAMO,2CACPC,EAAmC,
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n CallTaskInAppDeviceAction,\n DeviceManagementKit,\n type DeviceSessionId,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { inject, injectable } from \"inversify\";\n\nimport { GenerateTransactionDAReturnType } from \"@api/app-binder/GenerateTransactionDeviceActionTypes\";\nimport { GetAddressDAReturnType } from \"@api/app-binder/GetAddressDeviceActionTypes\";\nimport { GetAppConfigurationDAReturnType } from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport { SignMessageDAReturnType } from \"@api/app-binder/SignMessageDeviceActionTypes\";\nimport { SignTransactionDAReturnType } from \"@api/app-binder/SignTransactionDeviceActionTypes\";\nimport { SolanaTransactionOptionalConfig } from \"@api/model/SolanaTransactionOptionalConfig\";\nimport { Transaction } from \"@api/model/Transaction\";\nimport { SendSignMessageTask } from \"@internal/app-binder/task/SendSignMessageTask\";\nimport { externalTypes } from \"@internal/externalTypes\";\n\nimport { GetAppConfigurationCommand } from \"./command/GetAppConfigurationCommand\";\nimport { GetPubKeyCommand } from \"./command/GetPubKeyCommand\";\nimport { GenerateTransactionDeviceAction } from \"./device-action/GenerateTransactionDeviceAction\";\nimport { SignTransactionDeviceAction } from \"./device-action/SignTransactionDeviceAction\";\n\n@injectable()\nexport class SolanaAppBinder {\n constructor(\n @inject(externalTypes.Dmk) private dmk: DeviceManagementKit,\n @inject(externalTypes.SessionId) private sessionId: DeviceSessionId,\n @inject(externalTypes.ContextModule) private contextModule: ContextModule,\n ) {}\n\n getAddress(args: {\n derivationPath: string;\n checkOnDevice: boolean;\n skipOpenApp: boolean;\n }): GetAddressDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetPubKeyCommand(args),\n appName: \"Solana\",\n requiredUserInteraction: args.checkOnDevice\n ? UserInteractionRequired.VerifyAddress\n : UserInteractionRequired.None,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n signTransaction(args: {\n derivationPath: string;\n transaction: Transaction;\n solanaTransactionOptionalConfig?: SolanaTransactionOptionalConfig;\n }): SignTransactionDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SignTransactionDeviceAction({\n input: {\n derivationPath: args.derivationPath,\n transaction: args.transaction,\n transactionOptions: args.solanaTransactionOptionalConfig,\n contextModule: this.contextModule,\n },\n }),\n });\n }\n\n generateTransaction(args: {\n derivationPath: string;\n skipOpenApp: boolean;\n }): GenerateTransactionDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new GenerateTransactionDeviceAction({\n input: {\n derivationPath: args.derivationPath,\n skipOpenApp: args.skipOpenApp,\n contextModule: this.contextModule,\n },\n }),\n });\n }\n\n signMessage(args: {\n derivationPath: string;\n message: string;\n skipOpenApp: boolean;\n }): SignMessageDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new CallTaskInAppDeviceAction({\n input: {\n task: async (internalApi) =>\n new SendSignMessageTask(internalApi, {\n derivationPath: args.derivationPath,\n sendingData: new TextEncoder().encode(args.message),\n }).run(),\n appName: \"Solana\",\n requiredUserInteraction: UserInteractionRequired.SignPersonalMessage,\n skipOpenApp: args.skipOpenApp,\n },\n }),\n });\n }\n\n getAppConfiguration(): GetAppConfigurationDAReturnType {\n return this.dmk.executeDeviceAction({\n sessionId: this.sessionId,\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAppConfigurationCommand(),\n appName: \"Solana\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n }\n}\n"],
|
|
5
|
+
"mappings": "okBAAA,IAAAA,EAAA,GAAAC,EAAAD,EAAA,qBAAAE,IAAA,eAAAC,EAAAH,GACA,IAAAI,EAMO,2CACPC,EAAmC,qBASnCC,EAAoC,yDACpCC,EAA8B,mCAE9BC,EAA2C,gDAC3CC,EAAiC,sCACjCC,EAAgD,2DAChDC,EAA4C,uDAGrC,IAAMC,EAAN,KAAsB,CAC3B,YACqCC,EACMC,EACIC,EAC7C,CAHmC,SAAAF,EACM,eAAAC,EACI,mBAAAC,CAC5C,CAEH,WAAWC,EAIgB,CACzB,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,mBAAiBA,CAAI,EAClC,QAAS,SACT,wBAAyBA,EAAK,cAC1B,0BAAwB,cACxB,0BAAwB,KAC5B,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,gBAAgBA,EAIgB,CAC9B,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,8BAA4B,CAC5C,MAAO,CACL,eAAgBA,EAAK,eACrB,YAAaA,EAAK,YAClB,mBAAoBA,EAAK,gCACzB,cAAe,KAAK,aACtB,CACF,CAAC,CACH,CAAC,CACH,CAEA,oBAAoBA,EAGgB,CAClC,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,kCAAgC,CAChD,MAAO,CACL,eAAgBA,EAAK,eACrB,YAAaA,EAAK,YAClB,cAAe,KAAK,aACtB,CACF,CAAC,CACH,CAAC,CACH,CAEA,YAAYA,EAIgB,CAC1B,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,4BAA0B,CAC1C,MAAO,CACL,KAAM,MAAOC,GACX,IAAI,sBAAoBA,EAAa,CACnC,eAAgBD,EAAK,eACrB,YAAa,IAAI,YAAY,EAAE,OAAOA,EAAK,OAAO,CACpD,CAAC,EAAE,IAAI,EACT,QAAS,SACT,wBAAyB,0BAAwB,oBACjD,YAAaA,EAAK,WACpB,CACF,CAAC,CACH,CAAC,CACH,CAEA,qBAAuD,CACrD,OAAO,KAAK,IAAI,oBAAoB,CAClC,UAAW,KAAK,UAChB,aAAc,IAAI,+BAA6B,CAC7C,MAAO,CACL,QAAS,IAAI,6BACb,QAAS,SACT,wBAAyB,0BAAwB,KACjD,YAAa,EACf,CACF,CAAC,CACH,CAAC,CACH,CACF,EAhGaJ,EAANM,EAAA,IADN,cAAW,EAGPC,EAAA,eAAO,gBAAc,GAAG,GACxBA,EAAA,eAAO,gBAAc,SAAS,GAC9BA,EAAA,eAAO,gBAAc,aAAa,IAJ1BP",
|
|
6
6
|
"names": ["SolanaAppBinder_exports", "__export", "SolanaAppBinder", "__toCommonJS", "import_device_management_kit", "import_inversify", "import_SendSignMessageTask", "import_externalTypes", "import_GetAppConfigurationCommand", "import_GetPubKeyCommand", "import_GenerateTransactionDeviceAction", "import_SignTransactionDeviceAction", "SolanaAppBinder", "dmk", "sessionId", "contextModule", "args", "internalApi", "__decorateClass", "__decorateParam"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var o=require("@ledgerhq/device-management-kit"),
|
|
1
|
+
"use strict";var o=require("@ledgerhq/device-management-kit"),d=require("rxjs"),m=require("./command/GetAppConfigurationCommand"),l=require("./command/GetPubKeyCommand"),v=require("./device-action/GenerateTransactionDeviceAction"),D=require("./device-action/SignTransactionDeviceAction"),p=require("./SolanaAppBinder");describe("SolanaAppBinder",()=>{const a={},i={sendCommand:vi.fn(),executeDeviceAction:vi.fn()};beforeEach(()=>{vi.clearAllMocks()}),it("should be defined",()=>{const n=new p.SolanaAppBinder({},{},a);expect(n).toBeDefined()}),describe("getAddress",()=>{it("should return the address",()=>new Promise((n,s)=>{const t="D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5";vi.spyOn(i,"executeDeviceAction").mockReturnValue({observable:(0,d.from)([{status:o.DeviceActionStatus.Completed,output:t}]),cancel:vi.fn()});const c=new p.SolanaAppBinder(i,"sessionId",a),{observable:u}=c.getAddress({derivationPath:"44'/501'",checkOnDevice:!1,skipOpenApp:!1}),r=[];u.subscribe({next:e=>{r.push(e)},error:e=>{s(e)},complete:()=>{try{expect(r).toEqual([{status:o.DeviceActionStatus.Completed,output:t}]),n()}catch(e){s(e)}}})})),describe("calls of executeDeviceAction with the correct params",()=>{const n={derivationPath:"44'/60'/3'/2/1",returnChainCode:!1,skipOpenApp:!1};it("when checkOnDevice is true: UserInteractionRequired.VerifyAddress",()=>{const t={...n,checkOnDevice:!0};new p.SolanaAppBinder(i,"sessionId",a).getAddress(t),expect(i.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new o.SendCommandInAppDeviceAction({input:{command:new l.GetPubKeyCommand(t),appName:"Solana",requiredUserInteraction:o.UserInteractionRequired.VerifyAddress,skipOpenApp:!1}})})}),it("when checkOnDevice is false: UserInteractionRequired.None",()=>{const t={...n,checkOnDevice:!1};new p.SolanaAppBinder(i,"sessionId",a).getAddress(t),expect(i.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new o.SendCommandInAppDeviceAction({input:{command:new l.GetPubKeyCommand(t),appName:"Solana",requiredUserInteraction:o.UserInteractionRequired.None,skipOpenApp:!1}})})})})}),describe("signTransaction",()=>{it("should return the signature",()=>new Promise((n,s)=>{const t=new Uint8Array([1,2,3]);vi.spyOn(i,"executeDeviceAction").mockReturnValue({observable:(0,d.from)([{status:o.DeviceActionStatus.Completed,output:t}]),cancel:vi.fn()});const c=new p.SolanaAppBinder(i,"sessionId",a),{observable:u}=c.signTransaction({derivationPath:"44'/501'",transaction:new Uint8Array([1,2,3,4]),solanaTransactionOptionalConfig:{skipOpenApp:!1}}),r=[];u.subscribe({next:e=>{r.push(e)},error:e=>{s(e)},complete:()=>{try{expect(r).toEqual([{status:o.DeviceActionStatus.Completed,output:t}]),n()}catch(e){s(e)}}})})),it("should call executeDeviceAction with the correct params",()=>{const n="44'/60'/3'/2/1",s=new Uint8Array([1,2,3,4]),t=!1;new p.SolanaAppBinder(i,"sessionId",a).signTransaction({derivationPath:n,transaction:s,solanaTransactionOptionalConfig:{skipOpenApp:!1}}),expect(i.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new D.SignTransactionDeviceAction({input:{derivationPath:n,transaction:s,transactionOptions:{skipOpenApp:t},contextModule:a}})})})}),describe("signMessage",()=>{it("should return the signed message",()=>new Promise((n,s)=>{const t={signature:"signature"},c={derivationPath:"44'/501'/0'/0'",message:"Hello world",skipOpenApp:!1};vi.spyOn(i,"executeDeviceAction").mockReturnValue({observable:(0,d.from)([{status:o.DeviceActionStatus.Completed,output:t}]),cancel:vi.fn()});const u=new p.SolanaAppBinder(i,"sessionId",a),{observable:r}=u.signMessage(c),e=[];r.subscribe({next:A=>{e.push(A)},error:A=>{s(A)},complete:()=>{try{expect(e).toEqual([{status:o.DeviceActionStatus.Completed,output:t}]),n()}catch(A){s(A)}}})}))}),describe("getAppConfiguration",()=>{it("should return the app configuration",()=>new Promise((n,s)=>{const t={blindSigningEnabled:!0,pubKeyDisplayMode:"LONG",version:"2.5.10"};vi.spyOn(i,"executeDeviceAction").mockReturnValue({observable:(0,d.from)([{status:o.DeviceActionStatus.Completed,output:t}]),cancel:vi.fn()});const c=new p.SolanaAppBinder(i,"sessionId",a),{observable:u}=c.getAppConfiguration(),r=[];u.subscribe({next:e=>{r.push(e)},error:e=>{s(e)},complete:()=>{try{expect(r).toEqual([{status:o.DeviceActionStatus.Completed,output:t}]),n()}catch(e){s(e)}}})})),it("should call executeDeviceAction with the correct params",()=>{new p.SolanaAppBinder(i,"sessionId",a).getAppConfiguration(),expect(i.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new o.SendCommandInAppDeviceAction({input:{command:new m.GetAppConfigurationCommand,appName:"Solana",requiredUserInteraction:o.UserInteractionRequired.None,skipOpenApp:!1}})})})}),describe("generateTransaction",()=>{it("should return the serialized transaction",()=>new Promise((n,s)=>{const t="BASE64_OR_HEX_TX";vi.spyOn(i,"executeDeviceAction").mockReturnValue({observable:(0,d.from)([{status:o.DeviceActionStatus.Completed,output:t}]),cancel:vi.fn()});const c=new p.SolanaAppBinder(i,"sessionId",a),{observable:u}=c.generateTransaction({derivationPath:"44'/501'/0'/0'",skipOpenApp:!1}),r=[];u.subscribe({next:e=>r.push(e),error:e=>s(e),complete:()=>{try{expect(r).toEqual([{status:o.DeviceActionStatus.Completed,output:t}]),n()}catch(e){s(e)}}})})),it("should call executeDeviceAction with the correct params",()=>{const n="44'/501'/0'/0'";new p.SolanaAppBinder(i,"sessionId",a).generateTransaction({derivationPath:n,skipOpenApp:!0}),expect(i.executeDeviceAction).toHaveBeenCalledWith({sessionId:"sessionId",deviceAction:new v.GenerateTransactionDeviceAction({input:{derivationPath:n,skipOpenApp:!0,contextModule:a}})})})})});
|
|
2
2
|
//# sourceMappingURL=SolanaAppBinder.test.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../../../../src/internal/app-binder/SolanaAppBinder.test.ts"],
|
|
4
|
-
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type DeviceActionIntermediateValue,\n type DeviceActionState,\n DeviceActionStatus,\n type DeviceManagementKit,\n type DeviceSessionId,\n type DmkError,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { from } from \"rxjs\";\n\nimport {\n type GenerateTransactionDAError,\n type GenerateTransactionDAIntermediateValue,\n type GenerateTransactionDAOutput,\n} from \"@api/app-binder/GenerateTransactionDeviceActionTypes\";\nimport {\n type GetAppConfigurationDAError,\n type GetAppConfigurationDAIntermediateValue,\n type GetAppConfigurationDAOutput,\n} from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport {\n type GetAddressDAError,\n type GetAddressDAIntermediateValue,\n type GetAddressDAOutput,\n type SignTransactionDAError,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAOutput,\n} from \"@api/index\";\n\nimport { GetAppConfigurationCommand } from \"./command/GetAppConfigurationCommand\";\nimport { GetPubKeyCommand } from \"./command/GetPubKeyCommand\";\nimport { GenerateTransactionDeviceAction } from \"./device-action/GenerateTransactionDeviceAction\";\nimport { SignTransactionDeviceAction } from \"./device-action/SignTransactionDeviceAction\";\nimport { SolanaAppBinder } from \"./SolanaAppBinder\";\n\ndescribe(\"SolanaAppBinder\", () => {\n // stub ContextModule for tests\n const contextModuleStub: ContextModule = {} as ContextModule;\n\n const mockedDmk: DeviceManagementKit = {\n sendCommand: vi.fn(),\n executeDeviceAction: vi.fn(),\n } as unknown as DeviceManagementKit;\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it(\"should be defined\", () => {\n const binder = new SolanaAppBinder(\n {} as DeviceManagementKit,\n {} as DeviceSessionId,\n contextModuleStub,\n );\n expect(binder).toBeDefined();\n });\n\n describe(\"getAddress\", () => {\n it(\"should return the address\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const address = \"D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: address,\n } as DeviceActionState<\n GetAddressDAOutput,\n GetAddressDAError,\n GetAddressDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.getAddress({\n derivationPath: \"44'/501'\",\n checkOnDevice: false,\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n GetAddressDAOutput,\n GetAddressDAError,\n GetAddressDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: address,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n describe(\"calls of executeDeviceAction with the correct params\", () => {\n const baseParams = {\n derivationPath: \"44'/60'/3'/2/1\",\n returnChainCode: false,\n skipOpenApp: false,\n };\n\n it(\"when checkOnDevice is true: UserInteractionRequired.VerifyAddress\", () => {\n // GIVEN\n const checkOnDevice = true;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n appBinder.getAddress(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetPubKeyCommand(params),\n appName: \"Solana\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n }),\n });\n });\n\n it(\"when checkOnDevice is false: UserInteractionRequired.None\", () => {\n // GIVEN\n const checkOnDevice = false;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n appBinder.getAddress(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetPubKeyCommand(params),\n appName: \"Solana\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n });\n });\n });\n\n describe(\"signTransaction\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature = new Uint8Array([0x01, 0x02, 0x03]);\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.signTransaction({\n derivationPath: \"44'/501'\",\n transaction: new Uint8Array([0x01, 0x02, 0x03, 0x04]),\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction with the correct params\", () => {\n // GIVEN\n const derivationPath = \"44'/60'/3'/2/1\";\n const transaction = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n const skipOpenApp = false;\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n appBinder.signTransaction({\n derivationPath,\n transaction,\n skipOpenApp,\n });\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SignTransactionDeviceAction({\n input: {\n derivationPath,\n transaction,\n skipOpenApp,\n contextModule: contextModuleStub,\n },\n }),\n });\n });\n });\n\n describe(\"signMessage\", () => {\n it(\"should return the signed message\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signedMessage = new Uint8Array([0x1c, 0x8a, 0x54, 0x05, 0x10]);\n const signMessageArgs = {\n derivationPath: \"44'/501'/0'/0'\",\n message: \"Hello world\",\n skipOpenApp: false,\n };\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signedMessage,\n } as DeviceActionState<\n Uint8Array,\n DmkError,\n DeviceActionIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.signMessage(signMessageArgs);\n\n // THEN\n const states: DeviceActionState<Uint8Array, unknown, unknown>[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signedMessage,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n\n describe(\"getAppConfiguration\", () => {\n it(\"should return the app configuration\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const appConfiguration = {\n blindSigningEnabled: true,\n pubKeyDisplayMode: \"LONG\",\n version: \"2.5.10\",\n };\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: appConfiguration,\n } as DeviceActionState<\n GetAppConfigurationDAOutput,\n GetAppConfigurationDAError,\n GetAppConfigurationDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.getAppConfiguration();\n\n // THEN\n const states: DeviceActionState<\n GetAppConfigurationDAOutput,\n GetAppConfigurationDAError,\n GetAppConfigurationDAIntermediateValue\n >[] = [];\n\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: appConfiguration,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction with the correct params\", () => {\n // GIVEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n\n // WHEN\n appBinder.getAppConfiguration();\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAppConfigurationCommand(),\n appName: \"Solana\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n });\n });\n\n describe(\"generateTransaction\", () => {\n it(\"should return the serialized transaction\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const serializedTx = \"BASE64_OR_HEX_TX\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: serializedTx,\n } as DeviceActionState<\n GenerateTransactionDAOutput,\n GenerateTransactionDAError,\n GenerateTransactionDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.generateTransaction({\n derivationPath: \"44'/501'/0'/0'\",\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n GenerateTransactionDAOutput,\n GenerateTransactionDAError,\n GenerateTransactionDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => states.push(state),\n error: (err) => reject(err),\n complete: () => {\n try {\n expect(states).toEqual([\n { status: DeviceActionStatus.Completed, output: serializedTx },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction with the correct params\", () => {\n // GIVEN\n const derivationPath = \"44'/501'/0'/0'\";\n const skipOpenApp = true;\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n appBinder.generateTransaction({ derivationPath, skipOpenApp });\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new GenerateTransactionDeviceAction({\n input: {\n derivationPath,\n skipOpenApp,\n contextModule: contextModuleStub,\n },\n }),\n });\n });\n });\n});\n"],
|
|
5
|
-
"mappings": "aACA,IAAAA,EASO,2CACPC,EAAqB,
|
|
4
|
+
"sourcesContent": ["import { type ContextModule } from \"@ledgerhq/context-module\";\nimport {\n type DeviceActionIntermediateValue,\n type DeviceActionState,\n DeviceActionStatus,\n type DeviceManagementKit,\n type DeviceSessionId,\n type DmkError,\n SendCommandInAppDeviceAction,\n UserInteractionRequired,\n} from \"@ledgerhq/device-management-kit\";\nimport { from } from \"rxjs\";\n\nimport {\n type GenerateTransactionDAError,\n type GenerateTransactionDAIntermediateValue,\n type GenerateTransactionDAOutput,\n} from \"@api/app-binder/GenerateTransactionDeviceActionTypes\";\nimport {\n type GetAppConfigurationDAError,\n type GetAppConfigurationDAIntermediateValue,\n type GetAppConfigurationDAOutput,\n} from \"@api/app-binder/GetAppConfigurationDeviceActionTypes\";\nimport {\n type GetAddressDAError,\n type GetAddressDAIntermediateValue,\n type GetAddressDAOutput,\n type SignMessageDAOutput,\n type SignTransactionDAError,\n type SignTransactionDAIntermediateValue,\n type SignTransactionDAOutput,\n} from \"@api/index\";\n\nimport { GetAppConfigurationCommand } from \"./command/GetAppConfigurationCommand\";\nimport { GetPubKeyCommand } from \"./command/GetPubKeyCommand\";\nimport { GenerateTransactionDeviceAction } from \"./device-action/GenerateTransactionDeviceAction\";\nimport { SignTransactionDeviceAction } from \"./device-action/SignTransactionDeviceAction\";\nimport { SolanaAppBinder } from \"./SolanaAppBinder\";\n\ndescribe(\"SolanaAppBinder\", () => {\n // stub ContextModule for tests\n const contextModuleStub: ContextModule = {} as ContextModule;\n\n const mockedDmk: DeviceManagementKit = {\n sendCommand: vi.fn(),\n executeDeviceAction: vi.fn(),\n } as unknown as DeviceManagementKit;\n\n beforeEach(() => {\n vi.clearAllMocks();\n });\n\n it(\"should be defined\", () => {\n const binder = new SolanaAppBinder(\n {} as DeviceManagementKit,\n {} as DeviceSessionId,\n contextModuleStub,\n );\n expect(binder).toBeDefined();\n });\n\n describe(\"getAddress\", () => {\n it(\"should return the address\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const address = \"D2PPQSYFe83nDzk96FqGumVU8JA7J8vj2Rhjc2oXzEi5\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: address,\n } as DeviceActionState<\n GetAddressDAOutput,\n GetAddressDAError,\n GetAddressDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.getAddress({\n derivationPath: \"44'/501'\",\n checkOnDevice: false,\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n GetAddressDAOutput,\n GetAddressDAError,\n GetAddressDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: address,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n describe(\"calls of executeDeviceAction with the correct params\", () => {\n const baseParams = {\n derivationPath: \"44'/60'/3'/2/1\",\n returnChainCode: false,\n skipOpenApp: false,\n };\n\n it(\"when checkOnDevice is true: UserInteractionRequired.VerifyAddress\", () => {\n // GIVEN\n const checkOnDevice = true;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n appBinder.getAddress(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetPubKeyCommand(params),\n appName: \"Solana\",\n requiredUserInteraction: UserInteractionRequired.VerifyAddress,\n skipOpenApp: false,\n },\n }),\n });\n });\n\n it(\"when checkOnDevice is false: UserInteractionRequired.None\", () => {\n // GIVEN\n const checkOnDevice = false;\n const params = {\n ...baseParams,\n checkOnDevice,\n };\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n appBinder.getAddress(params);\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetPubKeyCommand(params),\n appName: \"Solana\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n });\n });\n });\n\n describe(\"signTransaction\", () => {\n it(\"should return the signature\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signature = new Uint8Array([0x01, 0x02, 0x03]);\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n } as DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.signTransaction({\n derivationPath: \"44'/501'\",\n transaction: new Uint8Array([0x01, 0x02, 0x03, 0x04]),\n solanaTransactionOptionalConfig: { skipOpenApp: false },\n });\n\n // THEN\n const states: DeviceActionState<\n SignTransactionDAOutput,\n SignTransactionDAError,\n SignTransactionDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signature,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction with the correct params\", () => {\n // GIVEN\n const derivationPath = \"44'/60'/3'/2/1\";\n const transaction = new Uint8Array([0x01, 0x02, 0x03, 0x04]);\n const skipOpenApp = false;\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n appBinder.signTransaction({\n derivationPath,\n transaction,\n solanaTransactionOptionalConfig: { skipOpenApp: false },\n });\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SignTransactionDeviceAction({\n input: {\n derivationPath,\n transaction,\n transactionOptions: { skipOpenApp },\n contextModule: contextModuleStub,\n },\n }),\n });\n });\n });\n\n describe(\"signMessage\", () => {\n it(\"should return the signed message\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const signedMessage = {\n signature: \"signature\",\n };\n const signMessageArgs = {\n derivationPath: \"44'/501'/0'/0'\",\n message: \"Hello world\",\n skipOpenApp: false,\n };\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: signedMessage,\n } as DeviceActionState<\n SignMessageDAOutput,\n DmkError,\n DeviceActionIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.signMessage(signMessageArgs);\n\n // THEN\n const states: DeviceActionState<\n SignMessageDAOutput,\n unknown,\n unknown\n >[] = [];\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: signedMessage,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n });\n\n describe(\"getAppConfiguration\", () => {\n it(\"should return the app configuration\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const appConfiguration = {\n blindSigningEnabled: true,\n pubKeyDisplayMode: \"LONG\",\n version: \"2.5.10\",\n };\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: appConfiguration,\n } as DeviceActionState<\n GetAppConfigurationDAOutput,\n GetAppConfigurationDAError,\n GetAppConfigurationDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.getAppConfiguration();\n\n // THEN\n const states: DeviceActionState<\n GetAppConfigurationDAOutput,\n GetAppConfigurationDAError,\n GetAppConfigurationDAIntermediateValue\n >[] = [];\n\n observable.subscribe({\n next: (state) => {\n states.push(state);\n },\n error: (err) => {\n reject(err);\n },\n complete: () => {\n try {\n expect(states).toEqual([\n {\n status: DeviceActionStatus.Completed,\n output: appConfiguration,\n },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction with the correct params\", () => {\n // GIVEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n\n // WHEN\n appBinder.getAppConfiguration();\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new SendCommandInAppDeviceAction({\n input: {\n command: new GetAppConfigurationCommand(),\n appName: \"Solana\",\n requiredUserInteraction: UserInteractionRequired.None,\n skipOpenApp: false,\n },\n }),\n });\n });\n });\n\n describe(\"generateTransaction\", () => {\n it(\"should return the serialized transaction\", () =>\n new Promise<void>((resolve, reject) => {\n // GIVEN\n const serializedTx = \"BASE64_OR_HEX_TX\";\n\n vi.spyOn(mockedDmk, \"executeDeviceAction\").mockReturnValue({\n observable: from([\n {\n status: DeviceActionStatus.Completed,\n output: serializedTx,\n } as DeviceActionState<\n GenerateTransactionDAOutput,\n GenerateTransactionDAError,\n GenerateTransactionDAIntermediateValue\n >,\n ]),\n cancel: vi.fn(),\n });\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n const { observable } = appBinder.generateTransaction({\n derivationPath: \"44'/501'/0'/0'\",\n skipOpenApp: false,\n });\n\n // THEN\n const states: DeviceActionState<\n GenerateTransactionDAOutput,\n GenerateTransactionDAError,\n GenerateTransactionDAIntermediateValue\n >[] = [];\n observable.subscribe({\n next: (state) => states.push(state),\n error: (err) => reject(err),\n complete: () => {\n try {\n expect(states).toEqual([\n { status: DeviceActionStatus.Completed, output: serializedTx },\n ]);\n resolve();\n } catch (err) {\n reject(err as Error);\n }\n },\n });\n }));\n\n it(\"should call executeDeviceAction with the correct params\", () => {\n // GIVEN\n const derivationPath = \"44'/501'/0'/0'\";\n const skipOpenApp = true;\n\n // WHEN\n const appBinder = new SolanaAppBinder(\n mockedDmk,\n \"sessionId\",\n contextModuleStub,\n );\n appBinder.generateTransaction({ derivationPath, skipOpenApp });\n\n // THEN\n expect(mockedDmk.executeDeviceAction).toHaveBeenCalledWith({\n sessionId: \"sessionId\",\n deviceAction: new GenerateTransactionDeviceAction({\n input: {\n derivationPath,\n skipOpenApp,\n contextModule: contextModuleStub,\n },\n }),\n });\n });\n });\n});\n"],
|
|
5
|
+
"mappings": "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",
|
|
6
6
|
"names": ["import_device_management_kit", "import_rxjs", "import_GetAppConfigurationCommand", "import_GetPubKeyCommand", "import_GenerateTransactionDeviceAction", "import_SignTransactionDeviceAction", "import_SolanaAppBinder", "contextModuleStub", "mockedDmk", "binder", "resolve", "reject", "address", "appBinder", "observable", "states", "state", "err", "baseParams", "params", "signature", "derivationPath", "transaction", "skipOpenApp", "signedMessage", "signMessageArgs", "appConfiguration", "serializedTx"]
|
|
7
7
|
}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
"use strict";var
|
|
1
|
+
"use strict";var d=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var y=Object.getOwnPropertyNames;var A=Object.prototype.hasOwnProperty;var b=(o,e)=>{for(var r in e)d(o,r,{get:e[r],enumerable:!0})},P=(o,e,r,a)=>{if(e&&typeof e=="object"||typeof e=="function")for(let n of y(e))!A.call(o,n)&&n!==r&&d(o,n,{get:()=>e[n],enumerable:!(a=c(e,n))||a.enumerable});return o};var C=o=>P(d({},"__esModule",{value:!0}),o);var h={};b(h,{GetPubKeyCommand:()=>g});module.exports=C(h);var t=require("@ledgerhq/device-management-kit"),s=require("@ledgerhq/signer-utils"),m=require("purify-ts"),u=require("../../app-binder/services/bs58Encoder"),p=require("./utils/SolanaApplicationErrors");const i=32;class g{constructor(e,r=u.DefaultBs58Encoder){this.bs58Encoder=r;this.args=e}errorHelper=new s.CommandErrorHelper(p.SOLANA_APP_ERRORS,p.SolanaAppCommandErrorFactory);args;getApdu(){const e={cla:224,ins:5,p1:this.args.checkOnDevice?1:0,p2:0},r=new t.ApduBuilder(e),a=this.args.derivationPath,n=s.DerivationPathUtils.splitPath(a);return r.add8BitUIntToData(n.length),n.forEach(l=>{r.add32BitUIntToData(l)}),r.build()}parseResponse(e){return m.Maybe.fromNullable(this.errorHelper.getError(e)).orDefaultLazy(()=>{const r=new t.ApduParser(e);if(r.testMinimalLength(i)===!1)return(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Public key is missing")});const a=r.extractFieldByLength(i);return a===void 0?(0,t.CommandResultFactory)({error:new t.InvalidStatusWordError("Unable to extract public key")}):(0,t.CommandResultFactory)({data:this.bs58Encoder.encode(a)})})}}0&&(module.exports={GetPubKeyCommand});
|
|
2
2
|
//# sourceMappingURL=GetPubKeyCommand.js.map
|