-
Notifications
You must be signed in to change notification settings - Fork 99
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' of https://github.com/stellar/laboratory into sc-…
…contract-storage-filters
- Loading branch information
Showing
9 changed files
with
100 additions
and
35 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
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,11 +1,17 @@ | ||
const CONTRACT_LENGTH = 56; | ||
// https://developers.stellar.org/docs/learn/encyclopedia/contract-development/types/built-in-types#bytes-strings-bytes-bytesn-string | ||
// contract IDs are fixed 32-byte byte arrays, and are represented as BytesN<32> | ||
// A 32 byte binary array is equal to 256 bits (32 * 8) | ||
// To represent 256 bits in base32, we need at least 52 characters | ||
const CONTRACT_MIN_LENGTH = 52; | ||
|
||
export const getContractIdError = (value: string) => { | ||
if (value.charAt(0) !== "C") { | ||
return "The string must start with 'C'."; | ||
} else if (value.length !== CONTRACT_LENGTH) { | ||
return `The string must be exactly ${CONTRACT_LENGTH} characters long.`; | ||
} | ||
if (value.length < CONTRACT_MIN_LENGTH) { | ||
return `The string length should be at least ${CONTRACT_MIN_LENGTH} characters long.`; | ||
} | ||
// skipping max length check in case it includes metadata | ||
|
||
return false; | ||
}; |
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