Skip to content

Commit

Permalink
refactor(wallet-backend): supply addMeta to initIssuer
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelfig committed Sep 23, 2021
1 parent 9e02962 commit 25a0a2f
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
17 changes: 9 additions & 8 deletions packages/dapp-svelte-wallet/api/src/issuerTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ const makeIssuerTable = () => {
getByIssuer: issuerToIssuerRecord.get,
// `issuerP` may be a promise, presence, or local object. If there's
// already a record, return it. Otherwise, save the record.
initIssuer: async (issuerP, now = undefined) => {
initIssuer: async (issuerP, addMeta = x => x) => {
const brandP = E(issuerP).getBrand();
const brandIssuerMatchP = E(brandP).isMyIssuer(issuerP);
const displayInfoP = E(brandP).getDisplayInfo();
Expand All @@ -54,13 +54,14 @@ const makeIssuerTable = () => {
brandIssuerMatch,
`issuer was using a brand which was not its own`,
);
issuerTable.initIssuerByRecord({
creationStamp: now,
brand,
issuer,
assetKind: displayInfo.assetKind,
displayInfo,
});
issuerTable.initIssuerByRecord(
addMeta({
brand,
issuer,
assetKind: displayInfo.assetKind,
displayInfo,
}),
);
return issuerTable.getByBrand(brand);
},
initIssuerByRecord: issuerRecord => {
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-svelte-wallet/api/src/lib-wallet.js
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ export function makeWallet({
const issuer = await issuerP;
const recP = brandTable.hasByIssuer(issuer)
? brandTable.getByIssuer(issuer)
: brandTable.initIssuer(issuer, nowMs);
: brandTable.initIssuer(issuer, addMeta);
const { brand } = await recP;
await initIssuerToBoardId(issuer);
const addBrandPetname = () => {
Expand Down
2 changes: 1 addition & 1 deletion packages/dapp-svelte-wallet/api/src/types.js
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,6 @@
* @property {(brand: Brand) => IssuerRecord} getByBrand
* @property {(issuer: Issuer) => boolean} hasByIssuer
* @property {(issuer: Issuer) => IssuerRecord} getByIssuer
* @property {(issuerP: ERef<Issuer>, timestamp?: number) => Promise<IssuerRecord>} initIssuer
* @property {(issuerP: ERef<Issuer>, addMeta = x => x) => Promise<IssuerRecord>} initIssuer
* @property {(issuerRecord: IssuerRecord) => void } initIssuerByRecord
*/

0 comments on commit 25a0a2f

Please sign in to comment.