@midnight-ntwrk/wallet-sdk-facade 5.0.0-beta.2 → 5.0.0-beta.3
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 +40 -0
- package/dist/index.d.ts +418 -75
- package/dist/index.js +473 -108
- package/dist/transaction.d.ts +16 -4
- package/dist/transaction.js +115 -7
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -47,6 +47,46 @@ const facade = new WalletFacade(shieldedWallet, unshieldedWallet, dustWallet);
|
|
|
47
47
|
await facade.start(shieldedSecretKeys, dustSecretKey);
|
|
48
48
|
```
|
|
49
49
|
|
|
50
|
+
### Where the chain forks
|
|
51
|
+
|
|
52
|
+
Every configuration in the SDK carries `forks`, the protocol version from which each ledger version after the first
|
|
53
|
+
reads the chain. The wallet packages require it, because where a chain forks is a fact about the chain. The facade
|
|
54
|
+
presets it: left out of the configuration handed to `WalletFacade.init`, `forks` becomes `DefaultForkSchedule` —
|
|
55
|
+
`ProtocolVersion.V9NativeForkSchedule`, ledger-v9 from the version a 2.x node reports — and every factory in
|
|
56
|
+
`InitParams` is handed the configuration with it filled in, typed `ResolvedConfiguration`. That is why
|
|
57
|
+
`shielded: (config) => ShieldedWallet(config)` compiles against a wallet package that requires the field. Code outside a
|
|
58
|
+
factory that needs the same configuration — to build a wallet package directly, or to read `forks` back — gets it from
|
|
59
|
+
`WalletFacade.resolveConfiguration(configuration)`, and may hand the result to `init` as it is. A chain that hands over
|
|
60
|
+
elsewhere states its own `forks`, which wins.
|
|
61
|
+
|
|
62
|
+
### Configuring where proving happens
|
|
63
|
+
|
|
64
|
+
A transaction is proved by the backend for the ledger version that authored its bytes, never by the version the chain
|
|
65
|
+
has since reached. Backends are named per ledger version, keyed the way `forks` is, and the range each serves is read
|
|
66
|
+
off `forks` rather than restated:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const configuration = {
|
|
70
|
+
// ... the rest of the wallet configuration; `forks` may be left out, the facade presets `DefaultForkSchedule`
|
|
71
|
+
provers: {
|
|
72
|
+
// Below `forks.v9`: a proof server built against ledger-v8.
|
|
73
|
+
v8: { kind: 'server', url: new URL('http://localhost:6301') },
|
|
74
|
+
// From `forks.v9`: proving in this process, with the published circuits.
|
|
75
|
+
v9: { kind: 'wasm' },
|
|
76
|
+
},
|
|
77
|
+
};
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
`v9` is required, because it is what every new transaction is proved with. `v8` may be left out on a chain whose history
|
|
81
|
+
below the boundary the wallet never authors for; a transaction stamped there then fails with
|
|
82
|
+
`UnsupportedProvingVersionError`, naming the version.
|
|
83
|
+
|
|
84
|
+
One shorthand remains: `provingServerUrl: url` is one proof server under every key, read only when `provers` is absent.
|
|
85
|
+
The SDK drives it with each ledger version on its own side of `forks.v9`, so the same URL frames its requests correctly
|
|
86
|
+
on both. A proof server, though, is built against one ledger version: no published image serves both, so a chain with
|
|
87
|
+
history below the boundary wants `provers` with a server per side. The in-process prover works on bytes and does serve
|
|
88
|
+
both, under both keys.
|
|
89
|
+
|
|
50
90
|
### Observing Combined State
|
|
51
91
|
|
|
52
92
|
```typescript
|