Conversation
h33p
left a comment
There was a problem hiding this comment.
Implement nockbox/iris-sdk#3
| * @deprecated Remove when all dApps use iris-wasm 0.2.x | ||
| */ | ||
| export function toRawTx(rawTx: unknown): wasm.RawTx { | ||
| const asProtobuf = |
| return Number.isFinite(parsed) ? parsed : null; | ||
| } | ||
|
|
||
| function protobufSpendConditionToNative( |
There was a problem hiding this comment.
Expose and use a wasm method, like here:
https://github.com/nockbox/iris-rs/blob/main/crates/iris-wasm/src/tx.rs#L84
| export function toNote(note: unknown): wasm.Note { | ||
| if (note && typeof note === 'object' && ('version' in note || 'inner' in note)) { | ||
| return note as wasm.Note; | ||
| } |
…nt object shape checks
…uf so no need to normalize
package.json
Outdated
| "@fontsource/inter": "^5.2.8", | ||
| "@fontsource/lora": "^5.2.8", | ||
| "@nockbox/iris-sdk": "github:nockbox/iris-sdk#main", | ||
| "@nockbox/iris-sdk": "github:nockbox/iris-sdk#feat/sdk-v0-and-bridge-APIs", |
There was a problem hiding this comment.
note to change before submitting the new extension
| } | ||
|
|
||
| // Calculate network fee | ||
| // Calculate network fee. Logic based on iris-sdk/vendor/iris-wasm/iris_wasm.d.ts: |
There was a problem hiding this comment.
@h33p Is this the correct way to do these calculations? Since we're supporting 'native' signrawTX I noticed we should change how the display fee is calculated. Should probably double check
There was a problem hiding this comment.
also will remove the comment before the merge
There was a problem hiding this comment.
No, please convert protobuf to native format at the RPC boundary, or just use protobuf for now. Don't mix types in the extension.
| return spendCondition; | ||
| } | ||
| if (guard.isPbCom2SpendCondition(spendCondition)) { | ||
| return wasm.spendConditionFromProtobuf(spendCondition); |
There was a problem hiding this comment.
Added this to the WASM module
extension/background/index.ts
Outdated
| const outputs = await vault.computeOutputs(rawTxParams.rawTx); | ||
|
|
||
| // Create sign raw tx approval request | ||
| // Create sign raw tx approval request (payload validated as all-native or all-protobuf) |
There was a problem hiding this comment.
Payload is all protobuf, convert it to all native here.
extension/background/index.ts
Outdated
| } | ||
|
|
||
| /** Validates all-native or all-protobuf. */ | ||
| function isSignRawTxPayload(obj: unknown): obj is SignRawTxRequest { |
There was a problem hiding this comment.
This should be in SDK.
There should be an individual one for legacy and native.
| error: string; | ||
| }; | ||
|
|
||
| function parseNicksParam( |
There was a problem hiding this comment.
This is overly complicated. RPC should accept one type, and one type only.
Unless it was initially a number and we want to allow string int.
But also, unless I'm totally wrong, RPC boundary will never contain bigints. It's should all be JSON
extension/background/index.ts
Outdated
| sendResponse({ error: ERROR_CODES.BAD_ADDRESS }); | ||
| return; | ||
| } | ||
| const parsedSignAmount = parseNicksParam(signAmount, 'amount'); |
There was a problem hiding this comment.
Internal methods should use an always consistent type.
I would use Nicks, which is a string.
| return [{ Pkh: { m: 1, hashes: [senderPKH] } }]; | ||
| } | ||
|
|
||
| function createPkhCoinbaseCondition(senderPKH: string): SpendConditionLike { |
…f logic for better readibility, protobuf to native RPC boundary and internal proper handling
…n (decided to go with native representation since we convert that at boundary
5ad8e71 to
fb05d29
Compare
* don't collect incoming transactions * rehydrate state after service worker restart but have a custom lock time
No description provided.