Skip to content

Commit f7ae034

Browse files
authored
fix(rpc): use updated @agoric/rpc to avoid /custom vstorage route (0.50 sdk upgrade)
2 parents 6c3d891 + cda636c commit f7ae034

File tree

6 files changed

+200
-29
lines changed

6 files changed

+200
-29
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
"@agoric/cosmic-proto": "^0.5.0-u20.0",
2424
"@agoric/ertp": "^0.16.2",
2525
"@agoric/notifier": "^0.6.2",
26-
"@agoric/rpc": "^0.0.2-dev-2c6fbc5.0",
26+
"@agoric/rpc": "0.10.0",
2727
"@agoric/smart-wallet": "^0.5.3",
2828
"@agoric/ui-components": "~0.3.8",
2929
"@agoric/wallet-backend": "^0.14.3",

src/components/ProposeParamChange.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ export default function ProposeParamChange(props: Props) {
121121
transition={{ type: 'tween' }}
122122
>
123123
<form onSubmit={handleSubmit}>
124-
{Object.entries(data.current).map(([name, value]) => (
124+
{Object.entries(data.current || {}).map(([name, value]) => (
125125
<div className="mb-2" key={name}>
126126
<label className="block">
127127
<span className="text-gray-700">{paramLabel(name)}</span>

src/config.ts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ export const networkConfigUrl = (agoricNetName: string) => {
4545
export const rpcUrl = agoricNetSubdomain =>
4646
`https://${agoricNetSubdomain}.rpc.agoric.net:443`;
4747

48+
export const apiUrl = agoricNetSubdomain =>
49+
`https://${agoricNetSubdomain}.api.agoric.net:443`;
50+
4851
/**
4952
* Look up an archiving version of the host, if available.
5053
*/

src/lib/rpc.ts

Lines changed: 18 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010
makeLeader,
1111
} from '@agoric/casting';
1212
import { makeImportContext } from './makeImportContext';
13-
import { archivingAlternative, networkConfigUrl, rpcUrl } from 'config';
13+
import { archivingAlternative, networkConfigUrl, rpcUrl, apiUrl } from 'config';
1414
import {
1515
AgoricChainStoragePathKind,
1616
makeAgoricChainStorageWatcher,
@@ -31,7 +31,11 @@ export const marshal = makeImportContext().fromBoard;
3131
const fromAgoricNet = (str: string): Promise<MinimalNetworkConfig> => {
3232
const [netName, chainName] = str.split(',');
3333
if (chainName) {
34-
return Promise.resolve({ chainName, rpcAddrs: [rpcUrl(netName)] });
34+
return Promise.resolve({
35+
chainName,
36+
rpcAddrs: [rpcUrl(netName)],
37+
apiAddrs: [apiUrl(netName)],
38+
});
3539
}
3640
return fetch(networkConfigUrl(netName)).then(res => res.json());
3741
};
@@ -70,7 +74,7 @@ export const makeRpcUtils = async () => {
7074
const netConfigURL = networkConfigUrl(agoricNet);
7175
const networkConfig = await fromAgoricNet(agoricNet);
7276

73-
const { rpcAddrs, chainName } = networkConfig;
77+
const { rpcAddrs, chainName, apiAddrs } = networkConfig;
7478
const leader = makeLeader(archivingAlternative(chainName, rpcAddrs[0]), {});
7579

7680
const { vstorage: vst } = makeVstorageKit({ fetch }, { chainName, rpcAddrs });
@@ -89,11 +93,19 @@ export const makeRpcUtils = async () => {
8993
return response.children;
9094
},
9195
};
92-
96+
let didError = false;
9397
const storageWatcher = makeAgoricChainStorageWatcher(
94-
sample(rpcAddrs),
98+
sample(apiAddrs),
9599
chainName,
96-
marshal.unserialize,
100+
e => {
101+
if (didError) {
102+
console.error(e);
103+
return;
104+
}
105+
didError = true;
106+
notifyError(new Error('Error reading vstorage data for path "' + e));
107+
},
108+
marshal,
97109
);
98110

99111
return {
@@ -158,26 +170,12 @@ export const usePublishedDatum = (path?: string) => {
158170

159171
const { storageWatcher } = rpcUtils;
160172
setStatus(LoadStatus.Waiting);
161-
162-
let didError = false;
163173
return storageWatcher.watchLatest(
164174
[AgoricChainStoragePathKind.Data, `published.${path}`],
165175
value => {
166176
setData(value);
167177
setStatus(LoadStatus.Received);
168178
},
169-
e => {
170-
if (didError) {
171-
console.error(e);
172-
return;
173-
}
174-
didError = true;
175-
notifyError(
176-
new Error(
177-
'Error reading vstorage data for path "' + path + '": ' + e,
178-
),
179-
);
180-
},
181179
);
182180
}, [path, rpcUtils]);
183181

src/utils/networkConfig.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ export type MinimalNetworkConfig = {
1010
rpcAddrs: string[];
1111
chainName: string;
1212
notices?: NetworkNotice[];
13+
apiAddrs: string[];
1314
};
1415

1516
export const activeNotices = (

0 commit comments

Comments
 (0)