MCPcopy Create free account
hub / github.com/cardstack/cardstack / toChecksumAddress

Function toChecksumAddress

packages/cardpay-subgraph/src/utils.ts:158–175  ·  view source on GitHub ↗
(address: Address)

Source from the content-addressed store, hash-verified

156}
157
158export function toChecksumAddress(address: Address): string {
159 let lowerCaseAddress = address.toHex().slice(2);
160 let hash = crypto
161 .keccak256(ByteArray.fromUTF8(address.toHex().slice(2)))
162 .toHex()
163 .slice(2);
164 let result = '';
165
166 for (let i = 0; i < lowerCaseAddress.length; i++) {
167 if (parseInt(hash.charAt(i), 16) >= 8) {
168 result += toUpper(lowerCaseAddress.charAt(i));
169 } else {
170 result += lowerCaseAddress.charAt(i);
171 }
172 }
173
174 return toHex(result);
175}
176
177export function toHex(bytes: string): string {
178 return '0x' + bytes;

Callers 15

handleSwapFunction · 0.90
handlePrepaidCardSplitFunction · 0.90
handleMerchantClaimFunction · 0.90
handleMerchantCreationFunction · 0.90
handleProxyCreationFunction · 0.90
handleMerchantPaymentFunction · 0.90
handleMerchantFeeFunction · 0.90
handleMintFunction · 0.90
handleAddedOwnerFunction · 0.90
handleRemovedOwnerFunction · 0.90
handleExecutionSuccessFunction · 0.90

Calls 2

toUpperFunction · 0.85
toHexFunction · 0.85

Tested by

no test coverage detected