Skip to content

Commit 650f4f5

Browse files
committed
fix: improve wallet contents migration, but still not great
1 parent 50c2ad4 commit 650f4f5

File tree

5 files changed

+1031
-50
lines changed

5 files changed

+1031
-50
lines changed

lerna.json

+3-4
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,9 @@
88
"packages": [
99
".",
1010
"packages/*",
11-
"packages/agoric-cli/template/.agservers",
12-
"packages/agoric-cli/template/api",
13-
"packages/agoric-cli/template/contract",
14-
"packages/agoric-cli/template/ui"
11+
"packages/dapp-*-wallet/api",
12+
"packages/dapp-*-wallet/contract",
13+
"packages/dapp-*-wallet/ui"
1514
],
1615
"version": "independent"
1716
}

package.json

+3
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
"packages/sharing-service",
3535
"packages/zoe",
3636
"packages/dapp-react-wallet",
37+
"packages/dapp-svelte-wallet/ui",
38+
"packages/dapp-svelte-wallet/api",
39+
"packages/dapp-svelte-wallet",
3740
"packages/cosmic-swingset",
3841
"packages/agoric-cli",
3942
"packages/deployment",

packages/cosmic-swingset/lib/ag-solo/main.js

+8-1
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,14 @@ start
7070
const basedir = subArgs[0] || AG_SOLO_BASEDIR;
7171
const subdir = subArgs[1];
7272
assert(basedir !== undefined, 'you must provide a BASEDIR');
73-
initBasedir(basedir, webport, webhost, subdir, egresses.split(','));
73+
initBasedir(
74+
basedir,
75+
webport,
76+
webhost,
77+
subdir,
78+
egresses.split(','),
79+
subOpts,
80+
);
7481
await resetState(basedir);
7582

7683
// TODO: We may want to give some instructions. This is probably not the

packages/dapp-react-wallet/wallet-deploy.js

+25-13
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,6 @@ export default async function deployWallet(
6767
if (issuerToPetname.has(issuer)) {
6868
return issuerToPetname.get(issuer);
6969
}
70-
console.log('setting petname of', issuer, 'to', issuerPetname);
7170
issuerToPetname.set(issuer, issuerPetname);
7271
await E(wallet).addIssuer(issuerPetname, issuer);
7372
return issuerToPetname.get(issuer);
@@ -78,27 +77,40 @@ export default async function deployWallet(
7877
paymentInfo.map(async ({ pursePetname, issuer, payment, purse }) => {
7978
const issuerPetname = issuerToPetname.get(issuer);
8079

80+
let paymentP;
81+
82+
if (!payment && purse) {
83+
// Withdraw the payment from the purse.
84+
paymentP = E(purse)
85+
.getCurrentAmount()
86+
.then(amount => E(purse).withdraw(amount));
87+
} else {
88+
paymentP = E(issuer).isLive(payment).then(isLive => isLive && payment);
89+
}
90+
91+
payment = await paymentP;
92+
if (!payment) {
93+
return;
94+
}
95+
const amount = await E(issuer).getAmountOf(payment);
96+
97+
// TODO: Use AmountMath.
98+
const isEmpty = amount.value === 0 || (Array.isArray(amount.value) && !amount.value.length);
99+
if (isEmpty) {
100+
return;
101+
}
81102
if (!issuerToPursePetnameP.has(issuer)) {
82103
issuerToPursePetnameP.set(
83104
issuer,
84105
E(wallet)
85106
.makeEmptyPurse(issuerPetname, pursePetname)
86-
.then(_ => pursePetname),
107+
.then(_ => pursePetname, _ => pursePetname),
87108
);
88109
}
89110
pursePetname = await issuerToPursePetnameP.get(issuer);
90111

91-
let paymentP = payment;
92-
if (!paymentP) {
93-
// Withdraw the payment from the purse.
94-
paymentP = E(purse)
95-
.getCurrentAmount()
96-
.then(amount => E(purse).withdraw(amount));
97-
}
98-
99112
// Deposit payment.
100-
const p = await paymentP;
101-
await E(wallet).deposit(pursePetname, p);
113+
await E(wallet).deposit(pursePetname, payment);
102114
}),
103115
);
104116

@@ -108,5 +120,5 @@ export default async function deployWallet(
108120
await E(http).registerWallet(wallet, walletURLHandler, bridgeURLHandler);
109121
await E(walletVat).setHTTPObject(http);
110122
await E(walletVat).setPresences();
111-
console.log('Deployed @agoric/wallet-frontend!');
123+
console.log('Deployed Wallet!');
112124
}

0 commit comments

Comments
 (0)