-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: use the new registry and contract reference model
- Loading branch information
1 parent
2b4cdeb
commit 733b4aa
Showing
179 changed files
with
815 additions
and
17,947 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,22 @@ | ||
import { | ||
ContractFqn, | ||
ContractVersion, | ||
loadContract, | ||
ContractReference, | ||
findContractByReference, | ||
} from '@flair-sdk/registry'; | ||
import { useMemo } from 'react'; | ||
|
||
export type Config = { | ||
contractVersion?: ContractVersion; | ||
contractFqn: ContractFqn; | ||
contractReference: ContractReference; | ||
}; | ||
|
||
export const useContractAbi = ({ | ||
contractVersion = 'v1', | ||
contractFqn, | ||
}: Config) => { | ||
const contract = useMemo( | ||
() => loadContract(contractFqn, contractVersion), | ||
[contractFqn, contractVersion], | ||
); | ||
export const useContractAbi = ({ contractReference }: Config) => { | ||
const contract = useMemo(() => { | ||
try { | ||
return findContractByReference(contractReference); | ||
} catch (error) { | ||
console.warn(`Failed to find contract manifest for ${contractReference}`); | ||
return undefined; | ||
} | ||
}, [contractReference]); | ||
|
||
return contract?.artifact.abi || []; | ||
return contract?.artifact?.abi; | ||
}; |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import { | ||
ContractManifest, | ||
ContractReference, | ||
findContractByReference, | ||
} from '@flair-sdk/registry'; | ||
import { useEffect, useState } from 'react'; | ||
|
||
type Config = { | ||
contractReference?: ContractReference; | ||
}; | ||
|
||
export const useContractManifest = ({ contractReference }: Config) => { | ||
const [manifest, setManifest] = useState<ContractManifest>(); | ||
|
||
useEffect(() => { | ||
if (!contractReference) { | ||
setManifest(undefined); | ||
return; | ||
} | ||
|
||
try { | ||
const manifest = findContractByReference(contractReference); | ||
setManifest(manifest); | ||
} catch (error) { | ||
setManifest(undefined); | ||
} | ||
}, [contractReference]); | ||
|
||
return manifest; | ||
}; |
Oops, something went wrong.