Skip to content

Instantly share code, notes, and snippets.

@SuddenlyHazel
Created July 29, 2021 20:06
Show Gist options
  • Save SuddenlyHazel/5dc9de483bf3d0ddc468751906a34712 to your computer and use it in GitHub Desktop.
Save SuddenlyHazel/5dc9de483bf3d0ddc468751906a34712 to your computer and use it in GitHub Desktop.
nft-0.0.1.did
type Value =
variant {
Bool: bool;
Class: vec Property;
Empty;
Float: float64;
Int: int;
Nat: nat;
Principal: principal;
Text: text;
};
type UpdatedValue =
variant {
Bool: bool;
Float: float64;
Int: int;
Nat: nat;
Principal: principal;
Text: text;
};
type UpdateQuery =
record {
mode: variant {
Next: vec UpdateQuery;
Set: UpdatedValue;
};
name: text;
};
type UpdatePropertyRequest =
record {
id: text;
updateQuery: vec UpdateQuery;
};
type UpdateOwnersResult = Result;
type UpdateOwnersRequest =
record {
isAuthorized: bool;
user: principal;
};
type TransferResult = Result;
type TransferRequest =
record {
id: text;
to: principal;
};
type TopupCallback = func () -> ();
type StreamingStrategy = variant {
Callback:
record {
callback:
func (StreamingCallbackToken) ->
(StreamingCallbackHttpResponseBlob) query;
token: StreamingCallbackToken;
};};
type StreamingCallbackToken =
record {
content_encoding: text;
index: nat;
key: text;
sha256: opt vec nat8;
};
type StreamingCallbackHttpResponseBlob =
record {
body: blob;
token: opt StreamingCallbackToken;
};
type StagedWrite =
variant {
Chunk: record {
callback: opt Callback;
chunk: blob;
};
Init: record {
callback: opt Callback;
size: nat;
};
};
type Result_5 =
variant {
err: Error;
ok: principal;
};
type Result_4 =
variant {
err: Error;
ok: opt Property;
};
type Result_3 =
variant {
err: Error;
ok: PublicNft;
};
type Result_2 =
variant {
err: Error;
ok: Chunk;
};
type Result =
variant {
err: Error;
ok;
};
type PublicNft =
record {
contentType: text;
createdAt: int;
id: text;
owner: principal;
payload: PayloadResult;
properties: opt Property;
};
type PropertyQueryResult = Result_4;
type PropertyQueryRequest =
record {
id: text;
mode: variant {
All;
Some: PropertyQuery;
};
};
type PropertyQuery =
record {
name: text;
next: opt vec PropertyQuery;
};
type Property =
record {
immutable: bool;
name: text;
value: Value;
};
type PayloadResult =
variant {
Chunk: Chunk;
Complete: blob;
};
type OwnerOfResult = Result_5;
type NftResult = Result_3;
type NftEvent =
variant {
Authorize: record {
id: text;
isAuthorized: bool;
user: principal;
};
Transfer: record {
from: principal;
id: text;
to: principal;
};
};
type NftEgg =
record {
contentType: text;
isPrivate: bool;
owner: opt principal;
payload: variant {
Payload: vec nat8;
StagedData;
};
properties: opt Property;
};
type Nft =
service {
assetRequest: (AssetRequest) -> ();
authorize: (AuthorizeRequest) -> (AuthorizeResult);
balanceOf: (principal) -> (vec text);
balanceOfInsecure: (principal) -> (vec text) query;
getAuthorized: (text) -> (vec principal);
getAuthorizedInsecure: (text) -> (vec principal) query;
getContractInfo: () -> (ContractInfo);
getContractInfoInsecure: () -> (ContractInfo) query;
getEventCallbackStatus: () -> (EventCallbackStatus);
getMetadata: () -> (ContractMetadata) query;
getTotalMinted: () -> (nat) query;
http_request: (HttpRequest) -> (HttpResponseBlob) query;
http_request_streaming_callback: (StreamingCallbackToken) ->
(StreamingCallbackHttpResponseBlob) query;
init: (vec principal, ContractMetadata) -> ();
isAuthorized: (text, principal) -> (bool);
isAuthorizedInsecure: (text, principal) -> (bool) query;
listAssets: () -> (vec record {
text;
text;
nat;
}) query;
mint: (NftEgg) -> (text);
ownerOf: (text) -> (OwnerOfResult);
ownerOfInsecure: (text) -> (OwnerOfResult) query;
queryProperties: (PropertyQueryRequest) -> (PropertyQueryResult) query;
setEventCallback: (EventCallback) -> ();
tokenByIndex: (text) -> (NftResult);
tokenByIndexInsecure: (text) -> (NftResult) query;
tokenChunkByIndex: (text, nat) -> (ChunkResult);
tokenChunkByIndexInsecure: (text, nat) -> (ChunkResult) query;
transfer: (TransferRequest) -> (TransferResult);
updateContractOwners: (UpdateOwnersRequest) -> (UpdateOwnersResult);
updateProperties: (UpdatePropertyRequest) -> ();
wallet_receive: () -> ();
writeStaged: (StagedWrite) -> ();
};
type HttpResponseBlob =
record {
body: blob;
headers: vec HeaderField;
status_code: nat16;
streaming_strategy: opt StreamingStrategy;
};
type HttpRequest =
record {
body: blob;
headers: vec HeaderField;
method: text;
url: text;
};
type HeaderField =
record {
text;
text;
};
type EventMessage =
record {
createdAt: int;
event: variant {
ContractEvent: ContractEvent;
NftEvent: NftEvent;
};
topupAmount: nat;
topupCallback: TopupCallback;
};
type EventCallbackStatus =
record {
callback: opt EventCallback;
callsSinceLastTopup: nat;
failedCalls: nat;
failedCallsLimit: nat;
noTopupCallLimit: nat;
};
type EventCallback = func (EventMessage) -> ();
type Error =
variant {
AuthorizedPrincipalLimitReached: nat;
InvalidRequest;
NotFound;
Unauthorized;
};
type ContractMetadata =
record {
name: text;
symbol: text;
};
type ContractInfo =
record {
authorized_users: vec principal;
cycles: nat;
heap_size: nat;
max_live_size: nat;
memory_size: nat;
nft_payload_size: nat;
total_minted: nat;
};
type ContractEvent =
variant {
ContractAuthorize: record {
isAuthorized: bool;
user: principal;
};
Mint: record {
id: text;
owner: principal;
};
};
type ChunkResult = Result_2;
type Chunk =
record {
data: blob;
nextPage: opt nat;
totalPages: nat;
};
type Callback = func () -> ();
type AuthorizeResult = Result;
type AuthorizeRequest =
record {
id: text;
isAuthorized: bool;
user: principal;
};
type AssetRequest =
variant {
Put:
record {
callback: opt Callback;
contentType: text;
name: text;
payload: variant {
Payload: blob;
StagedData;
};
};
Remove: record {
callback: opt Callback;
name: text;
};
StagedWrite: StagedWrite;
};
service : () -> Nft
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment