MCPcopy Create free account
hub / github.com/PageLeay/celestial-runtime / constructor

Method constructor

lib.esm/contract/contract.js:35–61  ·  view source on GitHub ↗
(contract, fragment, args)

Source from the content-addressed store, hash-verified

33 #filter;
34 fragment;
35 constructor(contract, fragment, args) {
36 defineProperties(this, { fragment });
37 if (fragment.inputs.length < args.length) {
38 throw new Error("too many arguments");
39 }
40 // Recursively descend into args and resolve any addresses
41 const runner = getRunner(contract.runner, "resolveName");
42 const resolver = canResolve(runner) ? runner : null;
43 this.#filter = (async function () {
44 const resolvedArgs = await Promise.all(fragment.inputs.map((param, index) => {
45 const arg = args[index];
46 if (arg == null) {
47 return null;
48 }
49 return param.walkAsync(args[index], (type, value) => {
50 if (type === "address") {
51 if (Array.isArray(value)) {
52 return Promise.all(value.map((v) => resolveAddress(v, resolver)));
53 }
54 return resolveAddress(value, resolver);
55 }
56 return value;
57 });
58 }));
59 return contract.interface.encodeFilterTopics(fragment, resolvedArgs);
60 })();
61 }
62 getTopicFilter() {
63 return this.#filter;
64 }

Callers

nothing calls this directly

Calls 8

definePropertiesFunction · 0.90
resolveAddressFunction · 0.90
getRunnerFunction · 0.70
canResolveFunction · 0.70
mapMethod · 0.45
walkAsyncMethod · 0.45
isArrayMethod · 0.45
encodeFilterTopicsMethod · 0.45

Tested by

no test coverage detected