File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 11{
22 "name" : " @reclaimprotocol/js-sdk" ,
3- "version" : " 4.6.3 " ,
3+ "version" : " 4.6.4 " ,
44 "description" : " Designed to request proofs from the Reclaim protocol and manage the flow of claims and witness interactions." ,
55 "main" : " dist/index.js" ,
66 "types" : " dist/index.d.ts" ,
Original file line number Diff line number Diff line change 11import { ethers } from 'ethers' ;
22import type { WitnessData } from './utils/interfaces' ;
33import type { ClaimID , ClaimInfo , CompleteClaimData } from './utils/types' ;
4+ import { canonicalStringify } from './utils/strings' ;
45
56type BeaconState = {
67 witnesses : WitnessData [ ] ;
@@ -42,8 +43,20 @@ export function fetchWitnessListForClaim(
4243 return selectedWitnesses ;
4344}
4445
46+
4547export function getIdentifierFromClaimInfo ( info : ClaimInfo ) : ClaimID {
46- const str : string = `${ info . provider } \n${ info . parameters } \n${ info . context || '' } ` ;
48+ // re-canonicalize context if it's not empty
49+ let canonicalContext = info . context || '' ;
50+ if ( canonicalContext . length > 0 ) {
51+ try {
52+ const ctx = JSON . parse ( canonicalContext ) ;
53+ canonicalContext = canonicalStringify ( ctx ) ;
54+ } catch ( e ) {
55+ throw new Error ( 'unable to parse non-empty context. Must be JSON' ) ;
56+ }
57+ }
58+
59+ const str = `${ info . provider } \n${ info . parameters } \n${ canonicalContext } ` ;
4760 return ethers . keccak256 ( strToUint8Array ( str ) ) . toLowerCase ( ) ;
4861}
4962
You can’t perform that action at this time.
0 commit comments