-
Notifications
You must be signed in to change notification settings - Fork 100
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' into sc-contract-storage-csv
- Loading branch information
Showing
10 changed files
with
408 additions
and
126 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,9 @@ | ||
// 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; | ||
import { StrKey } from "@stellar/stellar-sdk"; | ||
|
||
export const getContractIdError = (value: string) => { | ||
if (value.charAt(0) !== "C") { | ||
return "The string must start with 'C'."; | ||
if (!StrKey.isValidContract(value)) { | ||
return "Invalid contract ID. Please enter a valid contract ID."; | ||
} | ||
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
Oops, something went wrong.