You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 

37 lines
849 B

import { Cell, beginCell, Address, beginDict, Slice, toNano } from "ton";
let contentSlice2 : Slice;
enum OPS {
ChangeAdmin = 3,
ReplaceMetadata = 4,
Mint = 21,
InternalTransfer = 0x178d4519,
Transfer = 0xf8a7ea5,
Burn = 0x595f07bc,
}
export type JettonMetaDataKeys =
| "name"
| "description"
| "image"
| "symbol"
| "image_data"
| "decimals";
async function parseJettonOffchainMetadata(contentSlice: Slice): Promise<{
metadata: { [s in JettonMetaDataKeys]?: string };
isIpfs: boolean;
}> {
const jsonURI = contentSlice
.loadBits(await () => (contentSlice.remainingBits()))
.toString("ascii")
.replace("ipfs://", "https://ipfs.io/ipfs/");
return {
metadata: (await axios.get(jsonURI)).data,
isIpfs: /(^|\/)ipfs[.:]/.test(jsonURI),
};
}