Skip to content

Commit

Permalink
feat: use source registry instead of hardcoded verifier registry
Browse files Browse the repository at this point in the history
  • Loading branch information
Trinketer22 authored Apr 12, 2024
1 parent a684846 commit 7b95abb
Showing 1 changed file with 13 additions and 5 deletions.
18 changes: 13 additions & 5 deletions src/cli/verify.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,13 +43,13 @@ type SourcesObject = {
const backends: Record<
'mainnet' | 'testnet',
{
verifierRegistry: Address;
sourceRegistry: Address;
backends: string[];
id: string;
}
> = {
mainnet: {
verifierRegistry: Address.parse('EQDS0AW7NV1w3nFwx-mmryfpH4OGQ3PXnoFGOJA_8PTHuLrw'),
sourceRegistry: Address.parse('EQD-BJSVUJviud_Qv7Ymfd3qzXdrmV525e3YDzWQoHIAiInL'),
backends: [
'https://ton-source-prod-1.herokuapp.com',
'https://ton-source-prod-2.herokuapp.com',
Expand All @@ -58,7 +58,7 @@ const backends: Record<
id: 'orbs.com',
},
testnet: {
verifierRegistry: Address.parse('EQB--CRXUbqYbqJKScEWeOrnk0TKJxB071M-WwvMpMEvq6Ed'),
sourceRegistry: Address.parse('EQCsdKYwUaXkgJkz2l0ol6qT_WxeRbE_wBCwnEybmR0u5TO8'),
backends: ['https://ton-source-prod-testnet-1.herokuapp.com'],
id: 'orbs-testnet',
},
Expand Down Expand Up @@ -97,6 +97,13 @@ class VerifierRegistry implements Contract {
});
}
}
class SourceRegistry implements Contract {
constructor(readonly address: Address) {}
async getVerifierRegistry(provider: ContractProvider) {
const { stack } = await provider.get('get_verifier_registry_address', []);
return stack.readAddress();
}
}

async function lookupCodeHash(hash: Buffer, ui: UIProvider, retryCount: number = 5): Promise<string | undefined> {
type QueryResponse = {
Expand Down Expand Up @@ -276,7 +283,8 @@ export const verify: Runner = async (args: Args, ui: UIProvider, context: Runner

const backend = backends[network];

const verifierRegistry = networkProvider.open(new VerifierRegistry(backend.verifierRegistry));
const sourceRegistry = networkProvider.open(new SourceRegistry(backend.sourceRegistry));
const verifierRegistry = networkProvider.open(new VerifierRegistry(await sourceRegistry.getVerifierRegistry()));

const verifier = (await verifierRegistry.getVerifiers()).find((v) => v.name === backend.id);
if (verifier === undefined) {
Expand Down Expand Up @@ -327,7 +335,7 @@ export const verify: Runner = async (args: Args, ui: UIProvider, context: Runner
const c = Cell.fromBoc(Buffer.from(msgCell.data))[0];

await networkProvider.sender().send({
to: backend.verifierRegistry,
to: verifierRegistry.address,
value: toNano('0.5'),
body: c,
});
Expand Down

0 comments on commit 7b95abb

Please sign in to comment.