diff --git a/candid/internal/candid/grammar.go b/candid/internal/candid/grammar.go index bb7f087..7f397fe 100755 --- a/candid/internal/candid/grammar.go +++ b/candid/internal/candid/grammar.go @@ -341,7 +341,9 @@ func Func(p *ast.Parser) (*ast.Node, error) { TypeStrings: NodeTypes, Value: op.And{ "func", - Sp, + op.Optional( + Sp, + ), FuncType, }, }, diff --git a/candid/internal/candid/grammar.pegn b/candid/internal/candid/grammar.pegn index 4a4607e..0bf0868 100644 --- a/candid/internal/candid/grammar.pegn +++ b/candid/internal/candid/grammar.pegn @@ -36,7 +36,7 @@ Variant <-- 'variant' Sp '{' Ws Fields? Ws '}' Fields <- FieldType (';' Ws FieldType)* ';'? RefType <- Func / Service / Principal -Func <-- 'func' Sp FuncType +Func <-- 'func' Sp? FuncType Service <-- 'service' Sp ActorType Principal <-- 'principal' diff --git a/gen/generator.go b/gen/generator.go index 5ebc11d..8e014dc 100644 --- a/gen/generator.go +++ b/gen/generator.go @@ -181,7 +181,7 @@ func (g *Generator) GenerateActor() ([]byte, error) { var argumentTypes []agentArgsMethodArgument for i, t := range f.ArgTypes { argumentTypes = append(argumentTypes, agentArgsMethodArgument{ - Name: fmt.Sprintf("arg%d", i), + Name: fmt.Sprintf("_arg%d", i), Type: g.dataToMotokoString(t.Data), }) } @@ -371,7 +371,7 @@ func (g *Generator) dataToGoReturnValue(definitions map[string]did.Data, prefix } else { name = *f.NameData } - return fmt.Sprintf("%s{\n%s: %s,\n}", g.dataToString(prefix, t), name, field) + return fmt.Sprintf("%s{\n%s: %s,\n}", g.dataToString(prefix, t), funcName("", name), field) default: switch data := data.(type) { case did.Primitive: @@ -422,7 +422,7 @@ func (g *Generator) dataToGoReturnValue(definitions map[string]did.Data, prefix } else { field = strings.TrimPrefix(field, "*") } - return fmt.Sprintf("%s{\n%s: %s,\n}", g.dataToString(prefix, data), name, field) + return fmt.Sprintf("%s{\n%s: %s,\n}", g.dataToString(prefix, data), funcName("", name), field) case did.Vector: switch t.Data.(type) { case did.DataId: @@ -512,7 +512,13 @@ func (g *Generator) dataToMotokoReturnValue(s rand.Source, definitions map[strin if field.Data != nil { return fmt.Sprintf("#%s(%s)", *field.Name, g.dataToMotokoReturnValue(s, definitions, *field.Data)) } - return fmt.Sprintf("#%s(%s)", *field.Name, g.dataToMotokoReturnValue(s, definitions, definitions[*field.NameData])) + if field.Name != nil { + return fmt.Sprintf("#%s(%s)", *field.Name, g.dataToMotokoReturnValue(s, definitions, definitions[*field.NameData])) + } + if data := definitions[*field.NameData]; data != nil { + return fmt.Sprintf("#%s(%s)", *field.NameData, g.dataToMotokoReturnValue(s, definitions, definitions[*field.NameData])) + } + return fmt.Sprintf("#%s", *field.NameData) case did.Optional: return fmt.Sprintf("?%s", g.dataToMotokoReturnValue(s, definitions, t.Data)) } @@ -531,14 +537,14 @@ func (g *Generator) dataToMotokoString(data did.Data) string { if v.Name != nil { var data string if v.NameData != nil { - data = fmt.Sprintf("T.%s", *v.NameData) + data = fmt.Sprintf("T.%s", funcName("", *v.NameData)) } else { data = g.dataToMotokoString(*v.Data) } fields = append(fields, fmt.Sprintf("%s : %s", *v.Name, data)) } else { if v.NameData != nil { - fields = append(fields, fmt.Sprintf("T.%s", *v.NameData)) + fields = append(fields, fmt.Sprintf("T.%s", funcName("", *v.NameData))) } else { fields = append(fields, g.dataToMotokoString(*v.Data)) } @@ -561,7 +567,7 @@ func (g *Generator) dataToMotokoString(data did.Data) string { if v.Name != nil { var data string if v.NameData != nil { - data = fmt.Sprintf("T.%s", *v.NameData) + data = fmt.Sprintf("T.%s", funcName("", *v.NameData)) } else { data = g.dataToMotokoString(*v.Data) } @@ -593,7 +599,7 @@ func (g *Generator) dataToMotokoString(data did.Data) string { case did.Principal: return "Principal" case did.DataId: - return fmt.Sprintf("T.%s", string(t)) + return fmt.Sprintf("T.%s", funcName("", string(t))) default: panic(fmt.Sprintf("unknown type: %T", t)) } @@ -706,7 +712,7 @@ func (g *Generator) dataToString(prefix string, data did.Data) string { originalName string name string typ string - }{originalName: name, name: name, typ: "idl.Null"}) + }{originalName: name, name: funcName("", name), typ: "idl.Null"}) } else { name := funcName("", *field.Name) if l := len(name); l > sizeName { diff --git a/gen/templates/actor_mo.gotmpl b/gen/templates/actor_mo.gotmpl index b181a34..1fb1b53 100644 --- a/gen/templates/actor_mo.gotmpl +++ b/gen/templates/actor_mo.gotmpl @@ -3,7 +3,7 @@ import T "types"; import { principalOfBlob } = "mo:⛔"; -actor class {{ .CanisterName }}() : async actor {} { +actor class _{{ .CanisterName }}() : async actor {} { {{- range .Methods }} public {{ .Type}} func {{ .Name }}({{ range $i, $e := .ArgumentTypes }}{{ if $i }}, {{ end }}{{ $e.Name }} : {{ $e.Type }}{{ end }}) : async ({{ range $i, $e := .ReturnTypes }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}) { ({{ range $i, $e := .ReturnValues }}{{ if $i }}, {{ end }}{{ $e }}{{ end }}) diff --git a/ic/assetstorage/actor.mo b/ic/assetstorage/actor.mo index 6e37d25..eb164d4 100755 --- a/ic/assetstorage/actor.mo +++ b/ic/assetstorage/actor.mo @@ -3,104 +3,113 @@ import T "types"; import { principalOfBlob } = "mo:⛔"; -actor class assetstorage() : async actor {} { +actor class _assetstorage() : async actor {} { public query func api_version() : async (Nat16) { (37567) }; - public query func get(arg0 : { key : T.Key; accept_encodings : [Text] }) : async ({ content : Blob; content_type : Text; content_encoding : Text; sha256 : ?Blob; total_length : Nat }) { + public query func get(_arg0 : { key : T.Key; accept_encodings : [Text] }) : async ({ content : Blob; content_type : Text; content_encoding : Text; sha256 : ?Blob; total_length : Nat }) { ({ content = "xD29BA3285331F6C7F0D655473EECC726ACDC040F58EA6EB25E7F29AF0D9A0D1C"; content_type = "16783008128760111668"; content_encoding = "17950520798700563169"; sha256 = ?"x9CB2427F6FE653F6B62FBA96D8F1E12A8E56D5C2F78BFBBC1AA2123F3F351627"; total_length = 6026846697888358752 }) }; - public query func get_chunk(arg0 : { key : T.Key; content_encoding : Text; index : Nat; sha256 : ?Blob }) : async ({ content : Blob }) { + public query func get_chunk(_arg0 : { key : T.Key; content_encoding : Text; index : Nat; sha256 : ?Blob }) : async ({ content : Blob }) { ({ content = "xD29BA3285331F6C7F0D655473EECC726ACDC040F58EA6EB25E7F29AF0D9A0D1C" }) }; - public query func list(arg0 : { }) : async ([{ key : T.Key; content_type : Text; encodings : [{ content_encoding : Text; sha256 : ?Blob; length : Nat; modified : T.Time }] }]) { + public query func list(_arg0 : { }) : async ([{ key : T.Key; content_type : Text; encodings : [{ content_encoding : Text; sha256 : ?Blob; length : Nat; modified : T.Time }] }]) { ([ { key = "10947193270334582983"; content_type = "14796593089282320071"; encodings = [ ] }, { key = "5581137331052452365"; content_type = "16783008128760111668"; encodings = [ { content_encoding = "12417521964141425308"; sha256 = ?"xF6B62FBA96D8F1E12A8E56D5C2F78BFBBC1AA2123F3F351627CDA4F460215FDF"; length = 6761596587761439523; modified = 10710614497258299314 } ] }, { key = "15136801312447304127"; content_type = "162152548071980469"; encodings = [ { content_encoding = "14077209220119134463"; sha256 = ?"xD3C55B521FA7E06E7250741B34B1DAA9B202CC3344785BC76BE335FD22FFB6C9"; length = 2084077193164783305; modified = 13391675440417614532 }, { content_encoding = "14968975491899110795"; sha256 = ?"x37C657F58FE763E151AE30313D91840FE735F3F6150AB1E806425DC06D370BF7"; length = 2352680325195863822; modified = 14128014930335967750 } ] }, { key = "3746323425543278841"; content_type = "8821984346850239251"; encodings = [ { content_encoding = "14462736655647055063"; sha256 = ?"xCFA664CF571B6486A80528C4DCAE1D1930B6D8706B4A7C18EE44C91F412FFD02"; length = 9929700925399154573; modified = 11088767165576575891 }, { content_encoding = "15046035820075230567"; sha256 = ?"x33CFD8BFE7A383ECAFF6D1758A17DAC3846F3083D3C758209A80969C406C0F9F"; length = 12055834449873493410; modified = 31796421242169405 }, { content_encoding = "11447805667579589575"; sha256 = ?"x36DB7871DEFE2A16CB43D7DBFF5C07226CA4A775F57295BA54EBD1D035949200"; length = 13617578955253855046; modified = 1594180888861903055 }, { content_encoding = "6239237605257051267"; sha256 = ?"x0A83E5B901801DC34B34B974BCC4F911C2DF37312B004FA56633078D52F45C95"; length = 6564397865503231339; modified = 17571980052175681961 }, { content_encoding = "14305891745011577671"; sha256 = ?"x121F7F91E31B2A591C27E24EA90A3729479AB9B9E9641D8A87074BFCDD4CA2E2"; length = 14483061483814533662; modified = 8636116459066836694 }, { content_encoding = "14155040766310771050"; sha256 = ?"xC8AB4E4984A709FFAE8CBE87BB5CE7F2DC81E2E7A27D7CB3A63FD6926CE2A6D0"; length = 5638244237989845542; modified = 11216713222199587111 }, { content_encoding = "11823872115486408554"; sha256 = ?"x950831FCD6D2699AF9998BFD7C850E5037142EB4093ABEF26890C5411F599E8D"; length = 9533094216574500419; modified = 16489285970588961804 }, { content_encoding = "10490462624386304549"; sha256 = ?"xEC5265FA86B9FDF91D5FC6B39FEC4535B8F2C60CE39721211ABDC925F8CC7C94"; length = 13758130762095906934; modified = 1365263110879385157 }, { content_encoding = "112410521269379018"; sha256 = ?"x8A2CF08ABE41AB318D2ED03D6B4D526C85BF2F14CDECB0C89BEEA288B3AAE000"; length = 14746017119238981010; modified = 5692415230495667644 } ] } ]) }; - public query func certified_tree(arg0 : { }) : async ({ certificate : Blob; tree : Blob }) { + public query func certified_tree(_arg0 : { }) : async ({ certificate : Blob; tree : Blob }) { ({ certificate = "xD29BA3285331F6C7F0D655473EECC726ACDC040F58EA6EB25E7F29AF0D9A0D1C"; tree = "x34623D11F938E9E1EACE7B8F0F1D9CB2427F6FE653F6B62FBA96D8F1E12A8E56" }) }; - public shared func create_batch(arg0 : { }) : async ({ batch_id : T.BatchId }) { + public shared func create_batch(_arg0 : { }) : async ({ batch_id : T.BatchId }) { ({ batch_id = 11310281747421436882 }) }; - public shared func create_chunk(arg0 : { batch_id : T.BatchId; content : Blob }) : async ({ chunk_id : T.ChunkId }) { + public shared func create_chunk(_arg0 : { batch_id : T.BatchId; content : Blob }) : async ({ chunk_id : T.ChunkId }) { ({ chunk_id = 11310281747421436882 }) }; - public shared func commit_batch(arg0 : T.CommitBatchArguments) : async () { + public shared func commit_batch(_arg0 : T.CommitBatchArguments) : async () { () }; - public shared func propose_commit_batch(arg0 : T.CommitBatchArguments) : async () { + public shared func propose_commit_batch(_arg0 : T.CommitBatchArguments) : async () { () }; - public shared func commit_proposed_batch(arg0 : T.CommitProposedBatchArguments) : async () { + public shared func commit_proposed_batch(_arg0 : T.CommitProposedBatchArguments) : async () { () }; - public shared func compute_evidence(arg0 : T.ComputeEvidenceArguments) : async (?Blob) { + public shared func compute_evidence(_arg0 : T.ComputeEvidenceArguments) : async (?Blob) { (?"xD29BA3285331F6C7F0D655473EECC726ACDC040F58EA6EB25E7F29AF0D9A0D1C") }; - public shared func delete_batch(arg0 : T.DeleteBatchArguments) : async () { + public shared func delete_batch(_arg0 : T.DeleteBatchArguments) : async () { () }; - public shared func create_asset(arg0 : T.CreateAssetArguments) : async () { + public shared func create_asset(_arg0 : T.CreateAssetArguments) : async () { () }; - public shared func set_asset_content(arg0 : T.SetAssetContentArguments) : async () { + public shared func set_asset_content(_arg0 : T.SetAssetContentArguments) : async () { () }; - public shared func unset_asset_content(arg0 : T.UnsetAssetContentArguments) : async () { + public shared func unset_asset_content(_arg0 : T.UnsetAssetContentArguments) : async () { () }; - public shared func delete_asset(arg0 : T.DeleteAssetArguments) : async () { + public shared func delete_asset(_arg0 : T.DeleteAssetArguments) : async () { () }; - public shared func clear(arg0 : T.ClearArguments) : async () { + public shared func clear(_arg0 : T.ClearArguments) : async () { () }; - public shared func store(arg0 : { key : T.Key; content_type : Text; content_encoding : Text; content : Blob; sha256 : ?Blob }) : async () { + public shared func store(_arg0 : { key : T.Key; content_type : Text; content_encoding : Text; content : Blob; sha256 : ?Blob }) : async () { () }; - public query func http_request(arg0 : T.HttpRequest) : async (T.HttpResponse) { + public query func http_request(_arg0 : T.HttpRequest) : async (T.HttpResponse) { ({ status_code = 37567; headers = [ ( "14796593089282320071", "10425597289412325098" ), ( "5581137331052452365", "16783008128760111668" ), ( "17950520798700563169", "12417521964141425308" ), ( "5040047599884678902", "14841545318558739169" ), ( "11042565298778340235", "7634908469330851135" ) ]; body = "x60215FDF23A9A3239303A84504D6B2DF3A5323BFA3BF91167098B810B53D4123"; streaming_strategy = ?#Callback({ callback = { /* func */ }; token = { key = "14077209220119134463"; content_encoding = "3666113849647154643"; index = 10714402281011311214; sha256 = ?"xDAA9B202CC3344785BC76BE335FD22FFB6C97165F2C97E144F2A21ECC42A6A65" } }) }) }; - public query func http_request_streaming_callback(arg0 : T.StreamingCallbackToken) : async (?T.StreamingCallbackHttpResponse) { + public query func http_request_streaming_callback(_arg0 : T.StreamingCallbackToken) : async (?T.StreamingCallbackHttpResponse) { (?{ body = "xD29BA3285331F6C7F0D655473EECC726ACDC040F58EA6EB25E7F29AF0D9A0D1C"; token = ?{ key = "16783008128760111668"; content_encoding = "17950520798700563169"; index = 12417521964141425308; sha256 = ?"xF6B62FBA96D8F1E12A8E56D5C2F78BFBBC1AA2123F3F351627CDA4F460215FDF" } }) }; - public shared func authorize(arg0 : Principal) : async () { + public shared func authorize(_arg0 : Principal) : async () { () }; - public shared func deauthorize(arg0 : Principal) : async () { + public shared func deauthorize(_arg0 : Principal) : async () { () }; - public query func list_authorized() : async ([Principal]) { + public shared func list_authorized() : async ([Principal]) { ([ principalOfBlob("xC7F0D655473EECC726ACDC040F58EA6EB25E7F29AF0D9A0D1CD52E7434623D11"), principalOfBlob("xE1EACE7B8F0F1D9CB2427F6FE653F6B62FBA96D8F1E12A8E56D5C2F78BFBBC1A"), principalOfBlob("x3F351627CDA4F460215FDF23A9A3239303A84504D6B2DF3A5323BFA3BF911670"), principalOfBlob("xB53D4123E21440C05493AA5C742BFF000E92334B5CD3C55B521FA7E06E725074") ]) }; - public shared func grant_permission(arg0 : T.GrantPermission) : async () { + public shared func grant_permission(_arg0 : T.GrantPermission) : async () { () }; - public shared func revoke_permission(arg0 : T.RevokePermission) : async () { + public shared func revoke_permission(_arg0 : T.RevokePermission) : async () { () }; - public query func list_permitted(arg0 : T.ListPermitted) : async ([Principal]) { + public shared func list_permitted(_arg0 : T.ListPermitted) : async ([Principal]) { ([ principalOfBlob("xC7F0D655473EECC726ACDC040F58EA6EB25E7F29AF0D9A0D1CD52E7434623D11"), principalOfBlob("xE1EACE7B8F0F1D9CB2427F6FE653F6B62FBA96D8F1E12A8E56D5C2F78BFBBC1A"), principalOfBlob("x3F351627CDA4F460215FDF23A9A3239303A84504D6B2DF3A5323BFA3BF911670"), principalOfBlob("xB53D4123E21440C05493AA5C742BFF000E92334B5CD3C55B521FA7E06E725074") ]) }; public shared func take_ownership() : async () { () }; - public query func get_asset_properties(arg0 : T.Key) : async ({ max_age : ?Nat64; headers : ?[T.HeaderField]; allow_raw_access : ?Bool; is_aliased : ?Bool }) { + public query func get_asset_properties(_arg0 : T.Key) : async ({ max_age : ?Nat64; headers : ?[T.HeaderField]; allow_raw_access : ?Bool; is_aliased : ?Bool }) { ({ max_age = ?11310281747421436882; headers = ?[ ( "14796593089282320071", "10425597289412325098" ), ( "5581137331052452365", "16783008128760111668" ), ( "17950520798700563169", "12417521964141425308" ), ( "5040047599884678902", "14841545318558739169" ), ( "11042565298778340235", "7634908469330851135" ) ]; allow_raw_access = ?true; is_aliased = ?false }) }; - public shared func set_asset_properties(arg0 : T.SetAssetPropertiesArguments) : async () { + public shared func set_asset_properties(_arg0 : T.SetAssetPropertiesArguments) : async () { () }; - public shared func validate_grant_permission(arg0 : T.GrantPermission) : async (T.ValidationResult) { + public shared func get_configuration() : async (T.ConfigurationResponse) { + ({ max_batches = ?11310281747421436882; max_chunks = ?10947193270334582983; max_bytes = ?14796593089282320071 }) + }; + public shared func configure(_arg0 : T.ConfigureArguments) : async () { + () + }; + public shared func validate_grant_permission(_arg0 : T.GrantPermission) : async (T.ValidationResult) { (#Ok("10947193270334582983")) }; - public shared func validate_revoke_permission(arg0 : T.RevokePermission) : async (T.ValidationResult) { + public shared func validate_revoke_permission(_arg0 : T.RevokePermission) : async (T.ValidationResult) { (#Ok("10947193270334582983")) }; public shared func validate_take_ownership() : async (T.ValidationResult) { (#Ok("10947193270334582983")) }; - public shared func validate_commit_proposed_batch(arg0 : T.CommitProposedBatchArguments) : async (T.ValidationResult) { + public shared func validate_commit_proposed_batch(_arg0 : T.CommitProposedBatchArguments) : async (T.ValidationResult) { + (#Ok("10947193270334582983")) + }; + public shared func validate_configure(_arg0 : T.ConfigureArguments) : async (T.ValidationResult) { (#Ok("10947193270334582983")) }; } diff --git a/ic/assetstorage/agent.go b/ic/assetstorage/agent.go index 0decda2..b9ec719 100755 --- a/ic/assetstorage/agent.go +++ b/ic/assetstorage/agent.go @@ -127,6 +127,19 @@ func (a Agent) ComputeEvidence(arg0 ComputeEvidenceArguments) (**[]byte, error) return &r0, nil } +// Configure calls the "configure" method on the "assetstorage" canister. +func (a Agent) Configure(arg0 ConfigureArguments) error { + if err := a.a.Call( + a.canisterId, + "configure", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + // CreateAsset calls the "create_asset" method on the "assetstorage" canister. func (a Agent) CreateAsset(arg0 CreateAssetArguments) error { if err := a.a.Call( @@ -295,6 +308,20 @@ func (a Agent) GetChunk(arg0 struct { return &r0, nil } +// GetConfiguration calls the "get_configuration" method on the "assetstorage" canister. +func (a Agent) GetConfiguration() (*ConfigurationResponse, error) { + var r0 ConfigurationResponse + if err := a.a.Call( + a.canisterId, + "get_configuration", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + // GrantPermission calls the "grant_permission" method on the "assetstorage" canister. func (a Agent) GrantPermission(arg0 GrantPermission) error { if err := a.a.Call( @@ -372,7 +399,7 @@ func (a Agent) List(arg0 struct { // ListAuthorized calls the "list_authorized" method on the "assetstorage" canister. func (a Agent) ListAuthorized() (*[]principal.Principal, error) { var r0 []principal.Principal - if err := a.a.Query( + if err := a.a.Call( a.canisterId, "list_authorized", []any{}, @@ -386,7 +413,7 @@ func (a Agent) ListAuthorized() (*[]principal.Principal, error) { // ListPermitted calls the "list_permitted" method on the "assetstorage" canister. func (a Agent) ListPermitted(arg0 ListPermitted) (*[]principal.Principal, error) { var r0 []principal.Principal - if err := a.a.Query( + if err := a.a.Call( a.canisterId, "list_permitted", []any{arg0}, @@ -508,6 +535,20 @@ func (a Agent) ValidateCommitProposedBatch(arg0 CommitProposedBatchArguments) (* return &r0, nil } +// ValidateConfigure calls the "validate_configure" method on the "assetstorage" canister. +func (a Agent) ValidateConfigure(arg0 ConfigureArguments) (*ValidationResult, error) { + var r0 ValidationResult + if err := a.a.Call( + a.canisterId, + "validate_configure", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + // ValidateGrantPermission calls the "validate_grant_permission" method on the "assetstorage" canister. func (a Agent) ValidateGrantPermission(arg0 GrantPermission) (*ValidationResult, error) { var r0 ValidationResult @@ -550,6 +591,11 @@ func (a Agent) ValidateTakeOwnership() (*ValidationResult, error) { return &r0, nil } +type AssetCanisterArgs struct { + Init *InitArgs `ic:"Init,variant"` + Upgrade *UpgradeArgs `ic:"Upgrade,variant"` +} + type BatchId = idl.Nat type BatchOperationKind struct { @@ -581,6 +627,18 @@ type ComputeEvidenceArguments struct { MaxIterations *uint16 `ic:"max_iterations,omitempty" json:"max_iterations,omitempty"` } +type ConfigurationResponse struct { + MaxBatches *uint64 `ic:"max_batches,omitempty" json:"max_batches,omitempty"` + MaxChunks *uint64 `ic:"max_chunks,omitempty" json:"max_chunks,omitempty"` + MaxBytes *uint64 `ic:"max_bytes,omitempty" json:"max_bytes,omitempty"` +} + +type ConfigureArguments struct { + MaxBatches **uint64 `ic:"max_batches,omitempty" json:"max_batches,omitempty"` + MaxChunks **uint64 `ic:"max_chunks,omitempty" json:"max_chunks,omitempty"` + MaxBytes **uint64 `ic:"max_bytes,omitempty" json:"max_bytes,omitempty"` +} + type CreateAssetArguments struct { Key Key `ic:"key" json:"key"` ContentType string `ic:"content_type" json:"content_type"` @@ -623,6 +681,9 @@ type HttpResponse struct { StreamingStrategy *StreamingStrategy `ic:"streaming_strategy,omitempty" json:"streaming_strategy,omitempty"` } +type InitArgs struct { +} + type Key = string type ListPermitted struct { @@ -655,6 +716,12 @@ type SetAssetPropertiesArguments struct { IsAliased **bool `ic:"is_aliased,omitempty" json:"is_aliased,omitempty"` } +type SetPermissions struct { + Prepare []principal.Principal `ic:"prepare" json:"prepare"` + Commit []principal.Principal `ic:"commit" json:"commit"` + ManagePermissions []principal.Principal `ic:"manage_permissions" json:"manage_permissions"` +} + type StreamingCallbackHttpResponse struct { Body []byte `ic:"body" json:"body"` Token *StreamingCallbackToken `ic:"token,omitempty" json:"token,omitempty"` @@ -682,6 +749,10 @@ type UnsetAssetContentArguments struct { ContentEncoding string `ic:"content_encoding" json:"content_encoding"` } +type UpgradeArgs struct { + SetPermissions *SetPermissions `ic:"set_permissions,omitempty" json:"set_permissions,omitempty"` +} + type ValidationResult struct { Ok *string `ic:"Ok,variant"` Err *string `ic:"Err,variant"` diff --git a/ic/assetstorage/agent_test.go b/ic/assetstorage/agent_test.go index 27f015c..01192c9 100755 --- a/ic/assetstorage/agent_test.go +++ b/ic/assetstorage/agent_test.go @@ -192,6 +192,32 @@ func Test_ComputeEvidence(t *testing.T) { } +// Test_Configure tests the "configure" method on the "assetstorage" canister. +func Test_Configure(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "configure", + Arguments: []any{new(assetstorage.ConfigureArguments)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = assetstorage.ConfigureArguments{ + *new(**uint64), + *new(**uint64), + *new(**uint64), + } + if err := a.Configure(a0); err != nil { + t.Fatal(err) + } + +} + // Test_CreateAsset tests the "create_asset" method on the "assetstorage" canister. func Test_CreateAsset(t *testing.T) { a, err := newAgent([]mock.Method{ @@ -470,6 +496,31 @@ func Test_GetChunk(t *testing.T) { } +// Test_GetConfiguration tests the "get_configuration" method on the "assetstorage" canister. +func Test_GetConfiguration(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "get_configuration", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{assetstorage.ConfigurationResponse{ + *new(*uint64), + *new(*uint64), + *new(*uint64), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.GetConfiguration(); err != nil { + t.Fatal(err) + } + +} + // Test_GrantPermission tests the "grant_permission" method on the "assetstorage" canister. func Test_GrantPermission(t *testing.T) { a, err := newAgent([]mock.Method{ @@ -890,6 +941,34 @@ func Test_ValidateCommitProposedBatch(t *testing.T) { } +// Test_ValidateConfigure tests the "validate_configure" method on the "assetstorage" canister. +func Test_ValidateConfigure(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "validate_configure", + Arguments: []any{new(assetstorage.ConfigureArguments)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{assetstorage.ValidationResult{ + Ok: new(string), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = assetstorage.ConfigureArguments{ + *new(**uint64), + *new(**uint64), + *new(**uint64), + } + if _, err := a.ValidateConfigure(a0); err != nil { + t.Fatal(err) + } + +} + // Test_ValidateGrantPermission tests the "validate_grant_permission" method on the "assetstorage" canister. func Test_ValidateGrantPermission(t *testing.T) { a, err := newAgent([]mock.Method{ diff --git a/ic/assetstorage/types.mo b/ic/assetstorage/types.mo index fae4e91..366c65f 100755 --- a/ic/assetstorage/types.mo +++ b/ic/assetstorage/types.mo @@ -21,9 +21,15 @@ module T { public type StreamingCallbackToken = { key : T.Key; content_encoding : Text; index : Nat; sha256 : ?Blob }; public type StreamingStrategy = { #Callback : { callback : { /* func */ }; token : T.StreamingCallbackToken } }; public type SetAssetPropertiesArguments = { key : T.Key; max_age : ??Nat64; headers : ??[T.HeaderField]; allow_raw_access : ??Bool; is_aliased : ??Bool }; + public type ConfigurationResponse = { max_batches : ?Nat64; max_chunks : ?Nat64; max_bytes : ?Nat64 }; + public type ConfigureArguments = { max_batches : ??Nat64; max_chunks : ??Nat64; max_bytes : ??Nat64 }; public type Permission = { #Commit; #ManagePermissions; #Prepare }; public type GrantPermission = { to_principal : Principal; permission : T.Permission }; public type RevokePermission = { of_principal : Principal; permission : T.Permission }; public type ListPermitted = { permission : T.Permission }; public type ValidationResult = { #Ok : Text; #Err : Text }; + public type AssetCanisterArgs = { #Init : T.InitArgs; #Upgrade : T.UpgradeArgs }; + public type InitArgs = { }; + public type UpgradeArgs = { set_permissions : ?T.SetPermissions }; + public type SetPermissions = { prepare : [Principal]; commit : [Principal]; manage_permissions : [Principal] }; }; diff --git a/ic/cmc/actor.mo b/ic/cmc/actor.mo index ba63ad9..2cd1013 100755 --- a/ic/cmc/actor.mo +++ b/ic/cmc/actor.mo @@ -3,17 +3,29 @@ import T "types"; import { principalOfBlob } = "mo:⛔"; -actor class cmc() : async actor {} { - public shared func notify_top_up(arg0 : T.NotifyTopUpArg) : async (T.NotifyTopUpResult) { +actor class _cmc() : async actor {} { + public shared func notify_top_up(_arg0 : T.NotifyTopUpArg) : async (T.NotifyTopUpResult) { (#Ok(13928505266879913405)) }; - public shared func notify_create_canister(arg0 : T.NotifyCreateCanisterArg) : async (T.NotifyCreateCanisterResult) { + public shared func create_canister(_arg0 : T.CreateCanisterArg) : async (T.CreateCanisterResult) { (#Ok(principalOfBlob("xBDDD886CBEFD4B2A492BD37EED100C4A92C2724DFDEEA442723ED5975AE7B291"))) }; + public shared func notify_create_canister(_arg0 : T.NotifyCreateCanisterArg) : async (T.NotifyCreateCanisterResult) { + (#Ok(principalOfBlob("xBDDD886CBEFD4B2A492BD37EED100C4A92C2724DFDEEA442723ED5975AE7B291"))) + }; + public shared func notify_mint_cycles(_arg0 : T.NotifyMintCyclesArg) : async (T.NotifyMintCyclesResult) { + (#Ok({ block_index = 13928505266879913405; minted = 17010356921542854954; balance = 9294670361248549388 })) + }; public query func get_icp_xdr_conversion_rate() : async (T.IcpXdrConversionRateResponse) { ({ data = { timestamp_seconds = 7869213255852361324; xdr_permyriad_per_icp = 13928505266879913405 }; hash_tree = "x2A492BD37EED100C4A92C2724DFDEEA442723ED5975AE7B29122E0DDF194DD7E"; certificate = "x5528C3C9A6BA5F6F214EDB0ADC761D7824266830A884EE0F1DD3A30544A705F3" }) }; public query func get_subnet_types_to_subnets() : async (T.SubnetTypesToSubnetsResponse) { ({ data = [ ( "13928505266879913405", [ principalOfBlob("x0C4A92C2724DFDEEA442723ED5975AE7B29122E0DDF194DD7EA9FD965528C3C9"), principalOfBlob("x6F214EDB0ADC761D7824266830A884EE0F1DD3A30544A705F333F71702C7A660"), principalOfBlob("x951AC7ABA75404FF9F4FAA7D514C6DECB06637E868B117928E31FF4B3AF537E5"), principalOfBlob("x5560FF1A52DD6373BFBDD2A9248390071788F3C08BB33ED100CEF45D83C58237"), principalOfBlob("x7DF7405C7D3A4E4CABBE52B063DD16C97B3ADC25E4DCF546CF04F19365EFF436"), principalOfBlob("x42B7DFC7DFEC782917263A657D0DE6693F5C99FDE433CA01705CF05DD2070AE9") ] ), ( "4079598243291951032", [ principalOfBlob("xB9A37D98C2FAE8511AE12915936EAEEE9E788F297C09E28F0ADF120B0A296CEB"), principalOfBlob("xC2A3628B06F9DBA38FB72ED9EA2FA0155AA8C3454A0B6B7D243B879C0D565FF3"), principalOfBlob("xF96C562E9C04CE4151D4C6724C48A5DA0BDA2E89A4E3D812E5053A5878CF966B"), principalOfBlob("x7074BD42188B8EA0EA45A26782C1685E4ABFD47263EE88B87F20F20BDD7AC948"), principalOfBlob("xA589BEB48C3C69E8E292102556CA5C2482A9F277195ACF93DDE4EA792EF32DDD") ] ), ( "3237536108921815135", [ ] ), ( "2209486570766690869", [ principalOfBlob("x7A1A00D7528980DC4B5D2C61CD124CB667E538083C45AC24323A6B09F1937EBD"), principalOfBlob("x9784DDD5730BBE38F428F80C9C5075CB27A3C3C5B515DC9FEC1E1D8143D3F6D3"), principalOfBlob("x35AACBAB8D6525C9414CD74467FBE7DD91F2B774B08AEBE215950A3D06E2FC3C"), principalOfBlob("xBEBAA72E4D2773DBE87344D3B07940517CCF45A7E25F9D25DB14CCCF80D0129B"), principalOfBlob("x99C6BD7932FCCCD5EDDBD6FC58A31F4AE5BEA0F9682A1272F34D9CBB4554471B") ] ) ] }) }; + public query func get_principals_authorized_to_create_canisters_to_subnets() : async (T.PrincipalsAuthorizedToCreateCanistersToSubnetsResponse) { + ({ data = [ ( principalOfBlob("xBDDD886CBEFD4B2A492BD37EED100C4A92C2724DFDEEA442723ED5975AE7B291"), [ principalOfBlob("x5528C3C9A6BA5F6F214EDB0ADC761D7824266830A884EE0F1DD3A30544A705F3"), principalOfBlob("x02C7A660C5031A951AC7ABA75404FF9F4FAA7D514C6DECB06637E868B117928E"), principalOfBlob("x3AF537E5E30DF75560FF1A52DD6373BFBDD2A9248390071788F3C08BB33ED100"), principalOfBlob("x83C5823797B1967DF7405C7D3A4E4CABBE52B063DD16C97B3ADC25E4DCF546CF"), principalOfBlob("x65EFF436342DBA42B7DFC7DFEC782917263A657D0DE6693F5C99FDE433CA0170"), principalOfBlob("xD2070AE9151649B86FB9D5FCA49D87F65495F07A5DB9A37D98C2FAE8511AE129"), principalOfBlob("xAEEE9E788F297C09E28F0ADF120B0A296CEB9768F9C2A3628B06F9DBA38FB72E"), principalOfBlob("xA0155AA8C3454A0B6B7D243B879C0D565FF39B5FDAF96C562E9C04CE4151D4C6"), principalOfBlob("xA5DA0BDA2E89A4E3D812E5053A5878CF966B1A3EB47074BD42188B8EA0EA45A2") ] ), ( principalOfBlob("x685E4ABFD47263EE88B87F20F20BDD7AC948F85DF4A589BEB48C3C69E8E29210"), [ ] ), ( principalOfBlob("x5ACF93DDE4EA792EF32DDDF70D885F00C917F009EED039CC572B0356356A8B6A"), [ principalOfBlob("x7A1A00D7528980DC4B5D2C61CD124CB667E538083C45AC24323A6B09F1937EBD"), principalOfBlob("x9784DDD5730BBE38F428F80C9C5075CB27A3C3C5B515DC9FEC1E1D8143D3F6D3"), principalOfBlob("x35AACBAB8D6525C9414CD74467FBE7DD91F2B774B08AEBE215950A3D06E2FC3C"), principalOfBlob("xBEBAA72E4D2773DBE87344D3B07940517CCF45A7E25F9D25DB14CCCF80D0129B"), principalOfBlob("x99C6BD7932FCCCD5EDDBD6FC58A31F4AE5BEA0F9682A1272F34D9CBB4554471B") ] ), ( principalOfBlob("x25F4954F66910C12C6201C0CD32C59492FF31E3544840193875EC7073105AE3F"), [ principalOfBlob("xC11657DECEFB18CEE05F4EDE503F8CBF9BD011FB329862CD92D54E0711AD9BE7") ] ) ] }) + }; + public query func get_build_metadata() : async (Text) { + ("7869213255852361324") + }; } diff --git a/ic/cmc/agent.go b/ic/cmc/agent.go index 10e096b..cbf81ad 100755 --- a/ic/cmc/agent.go +++ b/ic/cmc/agent.go @@ -8,9 +8,7 @@ import ( "github.com/aviate-labs/agent-go/principal" ) -type AccountIdentifier struct { - Bytes []byte `ic:"bytes" json:"bytes"` -} +type AccountIdentifier = string // Agent is a client for the "cmc" canister. type Agent struct { @@ -30,6 +28,34 @@ func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, erro }, nil } +// CreateCanister calls the "create_canister" method on the "cmc" canister. +func (a Agent) CreateCanister(arg0 CreateCanisterArg) (*CreateCanisterResult, error) { + var r0 CreateCanisterResult + if err := a.a.Call( + a.canisterId, + "create_canister", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// GetBuildMetadata calls the "get_build_metadata" method on the "cmc" canister. +func (a Agent) GetBuildMetadata() (*string, error) { + var r0 string + if err := a.a.Query( + a.canisterId, + "get_build_metadata", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + // GetIcpXdrConversionRate calls the "get_icp_xdr_conversion_rate" method on the "cmc" canister. func (a Agent) GetIcpXdrConversionRate() (*IcpXdrConversionRateResponse, error) { var r0 IcpXdrConversionRateResponse @@ -44,6 +70,20 @@ func (a Agent) GetIcpXdrConversionRate() (*IcpXdrConversionRateResponse, error) return &r0, nil } +// GetPrincipalsAuthorizedToCreateCanistersToSubnets calls the "get_principals_authorized_to_create_canisters_to_subnets" method on the "cmc" canister. +func (a Agent) GetPrincipalsAuthorizedToCreateCanistersToSubnets() (*PrincipalsAuthorizedToCreateCanistersToSubnetsResponse, error) { + var r0 PrincipalsAuthorizedToCreateCanistersToSubnetsResponse + if err := a.a.Query( + a.canisterId, + "get_principals_authorized_to_create_canisters_to_subnets", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + // GetSubnetTypesToSubnets calls the "get_subnet_types_to_subnets" method on the "cmc" canister. func (a Agent) GetSubnetTypesToSubnets() (*SubnetTypesToSubnetsResponse, error) { var r0 SubnetTypesToSubnetsResponse @@ -72,6 +112,20 @@ func (a Agent) NotifyCreateCanister(arg0 NotifyCreateCanisterArg) (*NotifyCreate return &r0, nil } +// NotifyMintCycles calls the "notify_mint_cycles" method on the "cmc" canister. +func (a Agent) NotifyMintCycles(arg0 NotifyMintCyclesArg) (*NotifyMintCyclesResult, error) { + var r0 NotifyMintCyclesResult + if err := a.a.Call( + a.canisterId, + "notify_mint_cycles", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + // NotifyTopUp calls the "notify_top_up" method on the "cmc" canister. func (a Agent) NotifyTopUp(arg0 NotifyTopUpArg) (*NotifyTopUpResult, error) { var r0 NotifyTopUpResult @@ -88,6 +142,39 @@ func (a Agent) NotifyTopUp(arg0 NotifyTopUpArg) (*NotifyTopUpResult, error) { type BlockIndex = uint64 +type CanisterSettings struct { + Controller *principal.Principal `ic:"controller,omitempty" json:"controller,omitempty"` + Controllers *[]principal.Principal `ic:"controllers,omitempty" json:"controllers,omitempty"` + ComputeAllocation *idl.Nat `ic:"compute_allocation,omitempty" json:"compute_allocation,omitempty"` + MemoryAllocation *idl.Nat `ic:"memory_allocation,omitempty" json:"memory_allocation,omitempty"` + FreezingThreshold *idl.Nat `ic:"freezing_threshold,omitempty" json:"freezing_threshold,omitempty"` + ReservedCyclesLimit *idl.Nat `ic:"reserved_cycles_limit,omitempty" json:"reserved_cycles_limit,omitempty"` + LogVisibility *LogVisibility `ic:"log_visibility,omitempty" json:"log_visibility,omitempty"` + WasmMemoryLimit *idl.Nat `ic:"wasm_memory_limit,omitempty" json:"wasm_memory_limit,omitempty"` +} + +type CreateCanisterArg struct { + Settings *CanisterSettings `ic:"settings,omitempty" json:"settings,omitempty"` + SubnetType *string `ic:"subnet_type,omitempty" json:"subnet_type,omitempty"` + SubnetSelection *SubnetSelection `ic:"subnet_selection,omitempty" json:"subnet_selection,omitempty"` +} + +type CreateCanisterError struct { + Refunded *struct { + RefundAmount idl.Nat `ic:"refund_amount" json:"refund_amount"` + CreateError string `ic:"create_error" json:"create_error"` + } `ic:"Refunded,variant"` + RefundFailed *struct { + CreateError string `ic:"create_error" json:"create_error"` + RefundError string `ic:"refund_error" json:"refund_error"` + } `ic:"RefundFailed,variant"` +} + +type CreateCanisterResult struct { + Ok *principal.Principal `ic:"Ok,variant"` + Err *CreateCanisterError `ic:"Err,variant"` +} + type Cycles = idl.Nat type CyclesCanisterInitPayload struct { @@ -96,6 +183,7 @@ type CyclesCanisterInitPayload struct { MintingAccountId *AccountIdentifier `ic:"minting_account_id,omitempty" json:"minting_account_id,omitempty"` LastPurgedNotification *uint64 `ic:"last_purged_notification,omitempty" json:"last_purged_notification,omitempty"` ExchangeRateCanister *ExchangeRateCanister `ic:"exchange_rate_canister,omitempty" json:"exchange_rate_canister,omitempty"` + CyclesLedgerCanisterId *principal.Principal `ic:"cycles_ledger_canister_id,omitempty" json:"cycles_ledger_canister_id,omitempty"` } type ExchangeRateCanister struct { @@ -114,10 +202,19 @@ type IcpXdrConversionRateResponse struct { Certificate []byte `ic:"certificate" json:"certificate"` } +type LogVisibility struct { + Controllers *idl.Null `ic:"controllers,variant"` + Public *idl.Null `ic:"public,variant"` +} + +type Memo = *[]byte + type NotifyCreateCanisterArg struct { - BlockIndex BlockIndex `ic:"block_index" json:"block_index"` - Controller principal.Principal `ic:"controller" json:"controller"` - SubnetType *string `ic:"subnet_type,omitempty" json:"subnet_type,omitempty"` + BlockIndex BlockIndex `ic:"block_index" json:"block_index"` + Controller principal.Principal `ic:"controller" json:"controller"` + SubnetType *string `ic:"subnet_type,omitempty" json:"subnet_type,omitempty"` + SubnetSelection *SubnetSelection `ic:"subnet_selection,omitempty" json:"subnet_selection,omitempty"` + Settings *CanisterSettings `ic:"settings,omitempty" json:"settings,omitempty"` } type NotifyCreateCanisterResult struct { @@ -139,6 +236,23 @@ type NotifyError struct { } `ic:"Other,variant"` } +type NotifyMintCyclesArg struct { + BlockIndex BlockIndex `ic:"block_index" json:"block_index"` + ToSubaccount Subaccount `ic:"to_subaccount" json:"to_subaccount"` + DepositMemo Memo `ic:"deposit_memo" json:"deposit_memo"` +} + +type NotifyMintCyclesResult struct { + Ok *NotifyMintCyclesSuccess `ic:"Ok,variant"` + Err *NotifyError `ic:"Err,variant"` +} + +type NotifyMintCyclesSuccess struct { + BlockIndex idl.Nat `ic:"block_index" json:"block_index"` + Minted idl.Nat `ic:"minted" json:"minted"` + Balance idl.Nat `ic:"balance" json:"balance"` +} + type NotifyTopUpArg struct { BlockIndex BlockIndex `ic:"block_index" json:"block_index"` CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` @@ -149,6 +263,26 @@ type NotifyTopUpResult struct { Err *NotifyError `ic:"Err,variant"` } +type PrincipalsAuthorizedToCreateCanistersToSubnetsResponse struct { + Data []struct { + Field0 principal.Principal `ic:"0" json:"0"` + Field1 []principal.Principal `ic:"1" json:"1"` + } `ic:"data" json:"data"` +} + +type Subaccount = *[]byte + +type SubnetFilter struct { + SubnetType *string `ic:"subnet_type,omitempty" json:"subnet_type,omitempty"` +} + +type SubnetSelection struct { + Subnet *struct { + Subnet principal.Principal `ic:"subnet" json:"subnet"` + } `ic:"Subnet,variant"` + Filter *SubnetFilter `ic:"Filter,variant"` +} + type SubnetTypesToSubnetsResponse struct { Data []struct { Field0 string `ic:"0" json:"0"` diff --git a/ic/cmc/agent_test.go b/ic/cmc/agent_test.go index 44ec35f..7c207d1 100755 --- a/ic/cmc/agent_test.go +++ b/ic/cmc/agent_test.go @@ -13,6 +13,55 @@ import ( "github.com/aviate-labs/agent-go/ic/cmc" ) +// Test_CreateCanister tests the "create_canister" method on the "cmc" canister. +func Test_CreateCanister(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "create_canister", + Arguments: []any{new(cmc.CreateCanisterArg)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{cmc.CreateCanisterResult{ + Ok: new(principal.Principal), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = cmc.CreateCanisterArg{ + *new(*cmc.CanisterSettings), + *new(*string), + *new(*cmc.SubnetSelection), + } + if _, err := a.CreateCanister(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_GetBuildMetadata tests the "get_build_metadata" method on the "cmc" canister. +func Test_GetBuildMetadata(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "get_build_metadata", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(string)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.GetBuildMetadata(); err != nil { + t.Fatal(err) + } + +} + // Test_GetIcpXdrConversionRate tests the "get_icp_xdr_conversion_rate" method on the "cmc" canister. func Test_GetIcpXdrConversionRate(t *testing.T) { a, err := newAgent([]mock.Method{ @@ -41,6 +90,37 @@ func Test_GetIcpXdrConversionRate(t *testing.T) { } +// Test_GetPrincipalsAuthorizedToCreateCanistersToSubnets tests the "get_principals_authorized_to_create_canisters_to_subnets" method on the "cmc" canister. +func Test_GetPrincipalsAuthorizedToCreateCanistersToSubnets(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "get_principals_authorized_to_create_canisters_to_subnets", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{cmc.PrincipalsAuthorizedToCreateCanistersToSubnetsResponse{ + []struct { + Field0 principal.Principal `ic:"0" json:"0"` + Field1 []principal.Principal `ic:"1" json:"1"` + }{ + + { + *new(principal.Principal), + []principal.Principal{*new(principal.Principal)}, + }}, + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.GetPrincipalsAuthorizedToCreateCanistersToSubnets(); err != nil { + t.Fatal(err) + } + +} + // Test_GetSubnetTypesToSubnets tests the "get_subnet_types_to_subnets" method on the "cmc" canister. func Test_GetSubnetTypesToSubnets(t *testing.T) { a, err := newAgent([]mock.Method{ @@ -93,6 +173,8 @@ func Test_NotifyCreateCanister(t *testing.T) { *new(uint64), *new(principal.Principal), *new(*string), + *new(*cmc.SubnetSelection), + *new(*cmc.CanisterSettings), } if _, err := a.NotifyCreateCanister(a0); err != nil { t.Fatal(err) @@ -100,6 +182,38 @@ func Test_NotifyCreateCanister(t *testing.T) { } +// Test_NotifyMintCycles tests the "notify_mint_cycles" method on the "cmc" canister. +func Test_NotifyMintCycles(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "notify_mint_cycles", + Arguments: []any{new(cmc.NotifyMintCyclesArg)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{cmc.NotifyMintCyclesResult{ + Ok: idl.Ptr(cmc.NotifyMintCyclesSuccess{ + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + }), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = cmc.NotifyMintCyclesArg{ + *new(uint64), + *new(*[]byte), + *new(*[]byte), + } + if _, err := a.NotifyMintCycles(a0); err != nil { + t.Fatal(err) + } + +} + // Test_NotifyTopUp tests the "notify_top_up" method on the "cmc" canister. func Test_NotifyTopUp(t *testing.T) { a, err := newAgent([]mock.Method{ diff --git a/ic/cmc/types.mo b/ic/cmc/types.mo index bba0829..b91a685 100755 --- a/ic/cmc/types.mo +++ b/ic/cmc/types.mo @@ -2,15 +2,28 @@ module T { public type Cycles = Nat; public type BlockIndex = Nat64; + public type LogVisibility = { #controllers; #public }; + public type CanisterSettings = { controller : ?Principal; controllers : ?[Principal]; compute_allocation : ?Nat; memory_allocation : ?Nat; freezing_threshold : ?Nat; reserved_cycles_limit : ?Nat; log_visibility : ?T.LogVisibility; wasm_memory_limit : ?Nat }; + public type Subaccount = ?Blob; + public type Memo = ?Blob; public type NotifyTopUpArg = { block_index : T.BlockIndex; canister_id : Principal }; - public type NotifyCreateCanisterArg = { block_index : T.BlockIndex; controller : Principal; subnet_type : ?Text }; + public type SubnetSelection = { #Subnet : { subnet : Principal }; #Filter : T.SubnetFilter }; + public type SubnetFilter = { subnet_type : ?Text }; + public type CreateCanisterArg = { settings : ?T.CanisterSettings; subnet_type : ?Text; subnet_selection : ?T.SubnetSelection }; + public type NotifyCreateCanisterArg = { block_index : T.BlockIndex; controller : Principal; subnet_type : ?Text; subnet_selection : ?T.SubnetSelection; settings : ?T.CanisterSettings }; + public type CreateCanisterError = { #Refunded : { refund_amount : Nat; create_error : Text }; #RefundFailed : { create_error : Text; refund_error : Text } }; public type NotifyError = { #Refunded : { reason : Text; block_index : ?T.BlockIndex }; #Processing; #TransactionTooOld : T.BlockIndex; #InvalidTransaction : Text; #Other : { error_code : Nat64; error_message : Text } }; public type NotifyTopUpResult = { #Ok : T.Cycles; #Err : T.NotifyError }; + public type CreateCanisterResult = { #Ok : Principal; #Err : T.CreateCanisterError }; public type NotifyCreateCanisterResult = { #Ok : Principal; #Err : T.NotifyError }; public type IcpXdrConversionRate = { timestamp_seconds : Nat64; xdr_permyriad_per_icp : Nat64 }; public type IcpXdrConversionRateResponse = { data : T.IcpXdrConversionRate; hash_tree : Blob; certificate : Blob }; public type SubnetTypesToSubnetsResponse = { data : [(Text, [Principal])] }; - public type AccountIdentifier = { bytes : Blob }; + public type PrincipalsAuthorizedToCreateCanistersToSubnetsResponse = { data : [(Principal, [Principal])] }; + public type AccountIdentifier = Text; public type ExchangeRateCanister = { #Set : Principal; #Unset }; - public type CyclesCanisterInitPayload = { ledger_canister_id : ?Principal; governance_canister_id : ?Principal; minting_account_id : ?T.AccountIdentifier; last_purged_notification : ?Nat64; exchange_rate_canister : ?T.ExchangeRateCanister }; + public type CyclesCanisterInitPayload = { ledger_canister_id : ?Principal; governance_canister_id : ?Principal; minting_account_id : ?T.AccountIdentifier; last_purged_notification : ?Nat64; exchange_rate_canister : ?T.ExchangeRateCanister; cycles_ledger_canister_id : ?Principal }; + public type NotifyMintCyclesArg = { block_index : T.BlockIndex; to_subaccount : T.Subaccount; deposit_memo : T.Memo }; + public type NotifyMintCyclesResult = { #Ok : T.NotifyMintCyclesSuccess; #Err : T.NotifyError }; + public type NotifyMintCyclesSuccess = { block_index : Nat; minted : Nat; balance : Nat }; }; diff --git a/ic/ic/actor.mo b/ic/ic/actor.mo new file mode 100755 index 0000000..bfc672e --- /dev/null +++ b/ic/ic/actor.mo @@ -0,0 +1,88 @@ +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +import T "types"; + +import { principalOfBlob } = "mo:⛔"; + +actor class _ic() : async actor {} { + public shared func create_canister(_arg0 : T.CreateCanisterArgs) : async (T.CreateCanisterResult) { + ({ canister_id = principalOfBlob("x869AF7A6140D470862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA0") }) + }; + public shared func update_settings(_arg0 : T.UpdateSettingsArgs) : async () { + () + }; + public shared func upload_chunk(_arg0 : T.UploadChunkArgs) : async (T.UploadChunkResult) { + ({ hash = "x869AF7A6140D470862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA0" }) + }; + public shared func clear_chunk_store(_arg0 : T.ClearChunkStoreArgs) : async () { + () + }; + public shared func stored_chunks(_arg0 : T.StoredChunksArgs) : async (T.StoredChunksResult) { + ([ { hash = "x0862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA00DA2FE1A254CA2" }, { hash = "x3D005FB6E22DF7BA41EBE7B21A1C13F932DE5C88E3F7CBBA21D83DB973446660" }, { hash = "x1A2AA3EF195DD53147822C629DF98B40FE3A93E721D185BD47D7EEE55135BB08" }, { hash = "x88544768FAFB19D706D81F6BD23CB10726A014187038BCE35CB2F3ECCB7DD75F" } ]) + }; + public shared func install_code(_arg0 : T.InstallCodeArgs) : async () { + () + }; + public shared func install_chunked_code(_arg0 : T.InstallChunkedCodeArgs) : async () { + () + }; + public shared func uninstall_code(_arg0 : T.UninstallCodeArgs) : async () { + () + }; + public shared func start_canister(_arg0 : T.StartCanisterArgs) : async () { + () + }; + public shared func stop_canister(_arg0 : T.StopCanisterArgs) : async () { + () + }; + public shared func canister_status(_arg0 : T.CanisterStatusArgs) : async (T.CanisterStatusResult) { + ({ status = #running; settings = { controllers = [ principalOfBlob("x9F515D2190E37D31EEC1BDFD5BBCE1B03FA00DA2FE1A254CA23FD9613D005FB6"), principalOfBlob("xBA41EBE7B21A1C13F932DE5C88E3F7CBBA21D83DB97344666081C6741A2AA3EF"), principalOfBlob("x3147822C629DF98B40FE3A93E721D185BD47D7EEE55135BB0860874988544768"), principalOfBlob("xD706D81F6BD23CB10726A014187038BCE35CB2F3ECCB7DD75F4647487E926B57"), principalOfBlob("x1AB600EF4AE294D7E2D2267FA77832A886DE6E4B72F4197FF183421A910092C0"), principalOfBlob("x472B7A3158CE1700CC21E6E714AF1108697FFC6D45094AEDFBE2A29AD1939D09"), principalOfBlob("x30190C629CD14D0FC80915A4320DA282A98A18083753F3DE7592A2198D6B99C8"), principalOfBlob("xEC8A4F529F93BB58C59A87D62A7717691617B8B442AFB32C31DF22DF57966FEA") ]; compute_allocation = 7181374305377412901; memory_allocation = 8483647216729911020; freezing_threshold = 14994143942249040469; reserved_cycles_limit = 14039119793643782529 }; module_hash = ?"xB34811D335EB789A5543731482481F165AAA1560662B8E9D514E23991BA4248F"; memory_size = 16803621580220603980; cycles = 9736605414087480391; reserved_cycles = 14670472641987634058; idle_cycles_burned_per_day = 2674853784875525116 }) + }; + public shared func canister_info(_arg0 : T.CanisterInfoArgs) : async (T.CanisterInfoResult) { + ({ total_num_changes = 15656497011928570502; recent_changes = [ { timestamp_nanos = 14519010981886906783; canister_version = 3800013330962312753; origin = #from_canister({ canister_id = principalOfBlob("x1A254CA23FD9613D005FB6E22DF7BA41EBE7B21A1C13F932DE5C88E3F7CBBA21"); canister_version = ?13363524253285500019 }); details = #code_deployment({ mode = #install; module_hash = "x8B40FE3A93E721D185BD47D7EEE55135BB0860874988544768FAFB19D706D81F" }) }, { timestamp_nanos = 18045950183738836913; canister_version = 5831303564926106680; origin = #from_canister({ canister_id = principalOfBlob("x7E926B574D40DD1AB600EF4AE294D7E2D2267FA77832A886DE6E4B72F4197FF1"); canister_version = ?15832102157618905233 }); details = #controllers_change({ controllers = [ principalOfBlob("x1108697FFC6D45094AEDFBE2A29AD1939D09B4D94630190C629CD14D0FC80915"), principalOfBlob("xA282A98A18083753F3DE7592A2198D6B99C8F949A2EC8A4F529F93BB58C59A87"), principalOfBlob("x17691617B8B442AFB32C31DF22DF57966FEA580488256723D7E15DA9ECEEEA00"), principalOfBlob("x554AD41C79E61581014BE311F9D4B34811D335EB789A5543731482481F165AAA"), principalOfBlob("x2B8E9D514E23991BA4248FFA389E4C1E233DCC74324754D490095F1F8A63C2F0"), principalOfBlob("xFC639D6958FD1EA1E5B346359864D5BE44010FF463BBE3FC7A6969524896FE46"), principalOfBlob("xC23A172820B58468A0172ED6160AAAD5CD022CD31A758DAED770BD742E48D130"), principalOfBlob("xF8C698FD6E1D95443E119353DE510A61BC14E1216A7498623DB922273C26F534") ] }) }, { timestamp_nanos = 10541212000563527943; canister_version = 2689134793603183504; origin = #from_canister({ canister_id = principalOfBlob("xFD0E74B0990E0078D2B236027D6B7FC5C5F87878D58678F82484F4E75D2F951C"); canister_version = ?14834280829257491391 }); details = #creation({ controllers = [ principalOfBlob("xD92065148671911683101A133588AE791A21EC626F4BF9C04EFC0618773EAA16"), principalOfBlob("xE6C4C477AF447EC1D59F4DE45FA855620A308ACE5E7985E23EEC83B6DE9E7A45"), principalOfBlob("x5C4698C942208D3A6C38A387F9DD652E440339C1E0698E3FF7D098E5ADF0DE50"), principalOfBlob("xEC36CC81E040F2487088112A24F71279CFCEF6E28B80B686F9CB5EF661C10795"), principalOfBlob("xDA90DE1A63AF6E2336D10DD0AA6B73AD0792645EEBDDE279F464613D0D3FEEFD"), principalOfBlob("xD7273B138C7BA77B24762E9719827530A112A44E62E38FBB862EA149FDD66F9A") ] }) }, { timestamp_nanos = 14116231344195082928; canister_version = 4523606734605955336; origin = #from_user({ user_id = principalOfBlob("x9A1B4EEAF85713EE92E855F1BEE87F3FE35C84FDD06850DAC8F040ACD17D576A") }); details = #code_deployment({ mode = #reinstall; module_hash = "x25B00214F7C6B8BA3F69EC1FBD8BC9CC09D1B95EB57A8B1D022B04E7DCDFA58E" }) }, { timestamp_nanos = 3481921817742942786; canister_version = 9192667871694660610; origin = #from_canister({ canister_id = principalOfBlob("x3A16C322D334F8042ED922291CB854D60A33E746222A023EA5020B7D41655642"); canister_version = ?10449616418252478675 }); details = #controllers_change({ controllers = [ principalOfBlob("xC4ED20EBB0444E73617ECA0ABBC443EDF0163E4F4B23AF8CCCD2A3190579A59D") ] }) }, { timestamp_nanos = 14686404346102099380; canister_version = 2250618464655299498; origin = #from_user({ user_id = principalOfBlob("x374DA7D7B5F718177360AE769AE8F5B227269DA9D837857A4238F0C809FCF065") }); details = #code_uninstall }, { timestamp_nanos = 9568659421456693105; canister_version = 848519729038390968; origin = #from_user({ user_id = principalOfBlob("xEC395D74A4E4E610A0DCE6AD5E24D0FC4A81F68D8B9F8E9A874E3492BAC55757") }); details = #controllers_change({ controllers = [ principalOfBlob("xC1B42179ADA7FAB19B81214F32C5CB41BA44AEB1B0A285FCA96DC7529E31667A"), principalOfBlob("x6F4A3BF6B1C5F5B4DA96F373CE56A20DF3491E602A349325524A8D03331CE083") ] }) }, { timestamp_nanos = 5550019485348043196; canister_version = 12412919251015282992; origin = #from_user({ user_id = principalOfBlob("xCDE635272898479BC9935BEF0A6C51CEB1EED82A478AFE75A02F087067D12A9F") }); details = #code_deployment({ mode = #upgrade; module_hash = "x75A4DDAF64344788F0A5E08AEF31457D2629F301DF60AB8177C3FFAC498B9074" }) } ]; module_hash = ?"x17E7C82BF52CA609FA741633E6A4BF64B753791583EE9B0C78A073DE0E38B9BD"; controllers = [ principalOfBlob("xEB51862AB2B4A466C1D3F906E8986CF0284AD909DE18D8F5933BFAE314FFEABD"), principalOfBlob("xDE3ACE7BC63AABA7506A20E9C93555300ABC7CD8ED3EB286AEDCB24CAB0812C6"), principalOfBlob("x9A18B820BE6164576BBE8F88910CBF148176C3B86DDA0B3E165458750059B587"), principalOfBlob("xD6BFE31BFBCAF99A799D55B2CA3E017C90144C96C3DE646E93B8D6136B7D83E0") ] }) + }; + public shared func delete_canister(_arg0 : T.DeleteCanisterArgs) : async () { + () + }; + public shared func deposit_cycles(_arg0 : T.DepositCyclesArgs) : async () { + () + }; + public shared func raw_rand() : async (T.RawRandResult) { + ("x869AF7A6140D470862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA0") + }; + public shared func http_request(_arg0 : T.HttpRequestArgs) : async (T.HttpRequestResult) { + ({ status = 15656497011928570502; headers = [ { name = "14519010981886906783"; value = "3800013330962312753" }, { name = "6412741098828968161"; value = "11484699392100541722" }, { name = "17507512528171630653"; value = "17445848412223914426" }, { name = "2946348513676687635"; value = "628601621483015159" }, { name = "13363524253285500019"; value = "17786224669345655322" }, { name = "11671532954286442289"; value = "18312172179401097355" }, { name = "11810108206237976017"; value = "8739665398422254929" }, { name = "6996900549006677128"; value = "11041931743943198423" } ]; body = "xB10726A014187038BCE35CB2F3ECCB7DD75F4647487E926B574D40DD1AB600EF" }) + }; + public shared func ecdsa_public_key(_arg0 : T.EcdsaPublicKeyArgs) : async (T.EcdsaPublicKeyResult) { + ({ public_key = "x869AF7A6140D470862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA0"; chain_code = "x1A254CA23FD9613D005FB6E22DF7BA41EBE7B21A1C13F932DE5C88E3F7CBBA21" }) + }; + public shared func sign_with_ecdsa(_arg0 : T.SignWithEcdsaArgs) : async (T.SignWithEcdsaResult) { + ({ signature = "x869AF7A6140D470862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA0" }) + }; + public shared func bitcoin_get_balance(_arg0 : T.BitcoinGetBalanceArgs) : async (T.BitcoinGetBalanceResult) { + (15656497011928570502) + }; + public query func bitcoin_get_balance_query(_arg0 : T.BitcoinGetBalanceQueryArgs) : async (T.BitcoinGetBalanceQueryResult) { + (15656497011928570502) + }; + public shared func bitcoin_get_utxos(_arg0 : T.BitcoinGetUtxosArgs) : async (T.BitcoinGetUtxosResult) { + ({ utxos = [ { outpoint = { txid = "x0862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA00DA2FE1A254CA2"; vout = 2840997408 }; value = 17445848412223914426; height = 118915440 }, { outpoint = { txid = "xF7CBBA21D83DB97344666081C6741A2AA3EF195DD53147822C629DF98B40FE3A"; vout = 3953357992 }; value = 8739665398422254929; height = 3378598018 }, { outpoint = { txid = "xD706D81F6BD23CB10726A014187038BCE35CB2F3ECCB7DD75F4647487E926B57"; vout = 2056624229 }; value = 1763343418669589207; height = 3388535713 }, { outpoint = { txid = "xF4197FF183421A910092C007EDB6472B7A3158CE1700CC21E6E714AF1108697F"; vout = 92794092 }; value = 4919859010227508177; height = 2337925836 } ]; tip_block_hash = "x0FC80915A4320DA282A98A18083753F3DE7592A2198D6B99C8F949A2EC8A4F52"; tip_height = 2903633966; next_page = ?"x17691617B8B442AFB32C31DF22DF57966FEA580488256723D7E15DA9ECEEEA00" }) + }; + public query func bitcoin_get_utxos_query(_arg0 : T.BitcoinGetUtxosQueryArgs) : async (T.BitcoinGetUtxosQueryResult) { + ({ utxos = [ { outpoint = { txid = "x0862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA00DA2FE1A254CA2"; vout = 2840997408 }; value = 17445848412223914426; height = 118915440 }, { outpoint = { txid = "xF7CBBA21D83DB97344666081C6741A2AA3EF195DD53147822C629DF98B40FE3A"; vout = 3953357992 }; value = 8739665398422254929; height = 3378598018 }, { outpoint = { txid = "xD706D81F6BD23CB10726A014187038BCE35CB2F3ECCB7DD75F4647487E926B57"; vout = 2056624229 }; value = 1763343418669589207; height = 3388535713 }, { outpoint = { txid = "xF4197FF183421A910092C007EDB6472B7A3158CE1700CC21E6E714AF1108697F"; vout = 92794092 }; value = 4919859010227508177; height = 2337925836 } ]; tip_block_hash = "x0FC80915A4320DA282A98A18083753F3DE7592A2198D6B99C8F949A2EC8A4F52"; tip_height = 2903633966; next_page = ?"x17691617B8B442AFB32C31DF22DF57966FEA580488256723D7E15DA9ECEEEA00" }) + }; + public shared func bitcoin_send_transaction(_arg0 : T.BitcoinSendTransactionArgs) : async () { + () + }; + public shared func bitcoin_get_current_fee_percentiles(_arg0 : T.BitcoinGetCurrentFeePercentilesArgs) : async (T.BitcoinGetCurrentFeePercentilesResult) { + ([ 14445098301504250376, 14519010981886906783, 3800013330962312753, 6412741098828968161 ]) + }; + public shared func node_metrics_history(_arg0 : T.NodeMetricsHistoryArgs) : async (T.NodeMetricsHistoryResult) { + ([ { timestamp_nanos = 14445098301504250376; node_metrics = [ { node_id = principalOfBlob("x31EEC1BDFD5BBCE1B03FA00DA2FE1A254CA23FD9613D005FB6E22DF7BA41EBE7"); num_blocks_total = 2946348513676687635; num_block_failures_total = 628601621483015159 }, { node_id = principalOfBlob("x7344666081C6741A2AA3EF195DD53147822C629DF98B40FE3A93E721D185BD47"); num_blocks_total = 8739665398422254929; num_block_failures_total = 6996900549006677128 }, { node_id = principalOfBlob("xD706D81F6BD23CB10726A014187038BCE35CB2F3ECCB7DD75F4647487E926B57"); num_blocks_total = 10057912679290418714; num_block_failures_total = 1763343418669589207 }, { node_id = principalOfBlob("x32A886DE6E4B72F4197FF183421A910092C007EDB6472B7A3158CE1700CC21E6"); num_blocks_total = 16736904521429092369; num_block_failures_total = 692044588527733257 }, { node_id = principalOfBlob("xD1939D09B4D94630190C629CD14D0FC80915A4320DA282A98A18083753F3DE75"); num_blocks_total = 5377942242194975629; num_block_failures_total = 14536374534758435564 } ] }, { timestamp_nanos = 2699673602518336856; node_metrics = [ { node_id = principalOfBlob("xAFB32C31DF22DF57966FEA580488256723D7E15DA9ECEEEA0032F8BB554AD41C"); num_blocks_total = 14039119793643782529; num_block_failures_total = 3420742533394811059 }, { node_id = principalOfBlob("x9A5543731482481F165AAA1560662B8E9D514E23991BA4248FFA389E4C1E233D"); num_blocks_total = 9736605414087480391; num_block_failures_total = 14670472641987634058 }, { node_id = principalOfBlob("xFC639D6958FD1EA1E5B346359864D5BE44010FF463BBE3FC7A6969524896FE46"); num_blocks_total = 5874018963714161346; num_block_failures_total = 12468803627480752232 } ] }, { timestamp_nanos = 6060388434559489450; node_metrics = [ { node_id = principalOfBlob("x2E48D130F2D796F8C698FD6E1D95443E119353DE510A61BC14E1216A7498623D"); num_blocks_total = 14370068839309583932; num_block_failures_total = 10541212000563527943 }, { node_id = principalOfBlob("x9073DCDDD8B951CDB2FC3A3922F1FD0E74B0990E0078D2B236027D6B7FC5C5F8"); num_blocks_total = 4965205962592385158; num_block_failures_total = 11603411761932611421 }, { node_id = principalOfBlob("xBFA3479ED1F3DDB8E186099D10294826ED8361D159D92065148671911683101A"); num_blocks_total = 14947274454573152686; num_block_failures_total = 7716925642222139723 }, { node_id = principalOfBlob("x773EAA160280F8E6C4C477AF447EC1D59F4DE45FA855620A308ACE5E7985E23E"); num_blocks_total = 8782559658733379294; num_block_failures_total = 4291121491176080988 }, { node_id = principalOfBlob("x3A6C38A387F9DD652E440339C1E0698E3FF7D098E5ADF0DE507011E9EC36CC81"); num_blocks_total = 11022318376113958984; num_block_failures_total = 17477312328600877330 } ] }, { timestamp_nanos = 16930824079303685760; node_metrics = [ { node_id = principalOfBlob("xDA90DE1A63AF6E2336D10DD0AA6B73AD0792645EEBDDE279F464613D0D3FEEFD"); num_blocks_total = 13738085029865269207; num_block_failures_total = 17402500047223268475 }, { node_id = principalOfBlob("x7530A112A44E62E38FBB862EA149FDD66F9AA60B04B09AFBD59DEDE608B1C0A7"); num_blocks_total = 8262129053821897548; num_block_failures_total = 7283261748982717338 }, { node_id = principalOfBlob("xEE92E855F1BEE87F3FE35C84FDD06850DAC8F040ACD17D576AEF2F3A2A75B35E"); num_blocks_total = 8934560208994098493; num_block_failures_total = 11869455582429884453 } ] } ]) + }; + public shared func provisional_create_canister_with_cycles(_arg0 : T.ProvisionalCreateCanisterWithCyclesArgs) : async (T.ProvisionalCreateCanisterWithCyclesResult) { + ({ canister_id = principalOfBlob("x869AF7A6140D470862C22E5F4C779F515D2190E37D31EEC1BDFD5BBCE1B03FA0") }) + }; + public shared func provisional_top_up_canister(_arg0 : T.ProvisionalTopUpCanisterArgs) : async () { + () + }; +} diff --git a/ic/ic/agent.go b/ic/ic/agent.go new file mode 100755 index 0000000..1882fa9 --- /dev/null +++ b/ic/ic/agent.go @@ -0,0 +1,738 @@ +// Package ic provides a client for the "ic" canister. +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +package ic + +import ( + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/candid/idl" + "github.com/aviate-labs/agent-go/principal" +) + +// Agent is a client for the "ic" canister. +type Agent struct { + a *agent.Agent + canisterId principal.Principal +} + +// NewAgent creates a new agent for the "ic" canister. +func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, error) { + a, err := agent.New(config) + if err != nil { + return nil, err + } + return &Agent{ + a: a, + canisterId: canisterId, + }, nil +} + +// BitcoinGetBalance calls the "bitcoin_get_balance" method on the "ic" canister. +func (a Agent) BitcoinGetBalance(arg0 BitcoinGetBalanceArgs) (*BitcoinGetBalanceResult, error) { + var r0 BitcoinGetBalanceResult + if err := a.a.Call( + a.canisterId, + "bitcoin_get_balance", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// BitcoinGetBalanceQuery calls the "bitcoin_get_balance_query" method on the "ic" canister. +func (a Agent) BitcoinGetBalanceQuery(arg0 BitcoinGetBalanceQueryArgs) (*BitcoinGetBalanceQueryResult, error) { + var r0 BitcoinGetBalanceQueryResult + if err := a.a.Query( + a.canisterId, + "bitcoin_get_balance_query", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// BitcoinGetCurrentFeePercentiles calls the "bitcoin_get_current_fee_percentiles" method on the "ic" canister. +func (a Agent) BitcoinGetCurrentFeePercentiles(arg0 BitcoinGetCurrentFeePercentilesArgs) (*BitcoinGetCurrentFeePercentilesResult, error) { + var r0 BitcoinGetCurrentFeePercentilesResult + if err := a.a.Call( + a.canisterId, + "bitcoin_get_current_fee_percentiles", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// BitcoinGetUtxos calls the "bitcoin_get_utxos" method on the "ic" canister. +func (a Agent) BitcoinGetUtxos(arg0 BitcoinGetUtxosArgs) (*BitcoinGetUtxosResult, error) { + var r0 BitcoinGetUtxosResult + if err := a.a.Call( + a.canisterId, + "bitcoin_get_utxos", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// BitcoinGetUtxosQuery calls the "bitcoin_get_utxos_query" method on the "ic" canister. +func (a Agent) BitcoinGetUtxosQuery(arg0 BitcoinGetUtxosQueryArgs) (*BitcoinGetUtxosQueryResult, error) { + var r0 BitcoinGetUtxosQueryResult + if err := a.a.Query( + a.canisterId, + "bitcoin_get_utxos_query", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// BitcoinSendTransaction calls the "bitcoin_send_transaction" method on the "ic" canister. +func (a Agent) BitcoinSendTransaction(arg0 BitcoinSendTransactionArgs) error { + if err := a.a.Call( + a.canisterId, + "bitcoin_send_transaction", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// CanisterInfo calls the "canister_info" method on the "ic" canister. +func (a Agent) CanisterInfo(arg0 CanisterInfoArgs) (*CanisterInfoResult, error) { + var r0 CanisterInfoResult + if err := a.a.Call( + a.canisterId, + "canister_info", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// CanisterStatus calls the "canister_status" method on the "ic" canister. +func (a Agent) CanisterStatus(arg0 CanisterStatusArgs) (*CanisterStatusResult, error) { + var r0 CanisterStatusResult + if err := a.a.Call( + a.canisterId, + "canister_status", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ClearChunkStore calls the "clear_chunk_store" method on the "ic" canister. +func (a Agent) ClearChunkStore(arg0 ClearChunkStoreArgs) error { + if err := a.a.Call( + a.canisterId, + "clear_chunk_store", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// CreateCanister calls the "create_canister" method on the "ic" canister. +func (a Agent) CreateCanister(arg0 CreateCanisterArgs) (*CreateCanisterResult, error) { + var r0 CreateCanisterResult + if err := a.a.Call( + a.canisterId, + "create_canister", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// DeleteCanister calls the "delete_canister" method on the "ic" canister. +func (a Agent) DeleteCanister(arg0 DeleteCanisterArgs) error { + if err := a.a.Call( + a.canisterId, + "delete_canister", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// DepositCycles calls the "deposit_cycles" method on the "ic" canister. +func (a Agent) DepositCycles(arg0 DepositCyclesArgs) error { + if err := a.a.Call( + a.canisterId, + "deposit_cycles", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// EcdsaPublicKey calls the "ecdsa_public_key" method on the "ic" canister. +func (a Agent) EcdsaPublicKey(arg0 EcdsaPublicKeyArgs) (*EcdsaPublicKeyResult, error) { + var r0 EcdsaPublicKeyResult + if err := a.a.Call( + a.canisterId, + "ecdsa_public_key", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// HttpRequest calls the "http_request" method on the "ic" canister. +func (a Agent) HttpRequest(arg0 HttpRequestArgs) (*HttpRequestResult, error) { + var r0 HttpRequestResult + if err := a.a.Call( + a.canisterId, + "http_request", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// InstallChunkedCode calls the "install_chunked_code" method on the "ic" canister. +func (a Agent) InstallChunkedCode(arg0 InstallChunkedCodeArgs) error { + if err := a.a.Call( + a.canisterId, + "install_chunked_code", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// InstallCode calls the "install_code" method on the "ic" canister. +func (a Agent) InstallCode(arg0 InstallCodeArgs) error { + if err := a.a.Call( + a.canisterId, + "install_code", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// NodeMetricsHistory calls the "node_metrics_history" method on the "ic" canister. +func (a Agent) NodeMetricsHistory(arg0 NodeMetricsHistoryArgs) (*NodeMetricsHistoryResult, error) { + var r0 NodeMetricsHistoryResult + if err := a.a.Call( + a.canisterId, + "node_metrics_history", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ProvisionalCreateCanisterWithCycles calls the "provisional_create_canister_with_cycles" method on the "ic" canister. +func (a Agent) ProvisionalCreateCanisterWithCycles(arg0 ProvisionalCreateCanisterWithCyclesArgs) (*ProvisionalCreateCanisterWithCyclesResult, error) { + var r0 ProvisionalCreateCanisterWithCyclesResult + if err := a.a.Call( + a.canisterId, + "provisional_create_canister_with_cycles", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// ProvisionalTopUpCanister calls the "provisional_top_up_canister" method on the "ic" canister. +func (a Agent) ProvisionalTopUpCanister(arg0 ProvisionalTopUpCanisterArgs) error { + if err := a.a.Call( + a.canisterId, + "provisional_top_up_canister", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// RawRand calls the "raw_rand" method on the "ic" canister. +func (a Agent) RawRand() (*RawRandResult, error) { + var r0 RawRandResult + if err := a.a.Call( + a.canisterId, + "raw_rand", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// SignWithEcdsa calls the "sign_with_ecdsa" method on the "ic" canister. +func (a Agent) SignWithEcdsa(arg0 SignWithEcdsaArgs) (*SignWithEcdsaResult, error) { + var r0 SignWithEcdsaResult + if err := a.a.Call( + a.canisterId, + "sign_with_ecdsa", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// StartCanister calls the "start_canister" method on the "ic" canister. +func (a Agent) StartCanister(arg0 StartCanisterArgs) error { + if err := a.a.Call( + a.canisterId, + "start_canister", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// StopCanister calls the "stop_canister" method on the "ic" canister. +func (a Agent) StopCanister(arg0 StopCanisterArgs) error { + if err := a.a.Call( + a.canisterId, + "stop_canister", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// StoredChunks calls the "stored_chunks" method on the "ic" canister. +func (a Agent) StoredChunks(arg0 StoredChunksArgs) (*StoredChunksResult, error) { + var r0 StoredChunksResult + if err := a.a.Call( + a.canisterId, + "stored_chunks", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// UninstallCode calls the "uninstall_code" method on the "ic" canister. +func (a Agent) UninstallCode(arg0 UninstallCodeArgs) error { + if err := a.a.Call( + a.canisterId, + "uninstall_code", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// UpdateSettings calls the "update_settings" method on the "ic" canister. +func (a Agent) UpdateSettings(arg0 UpdateSettingsArgs) error { + if err := a.a.Call( + a.canisterId, + "update_settings", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil +} + +// UploadChunk calls the "upload_chunk" method on the "ic" canister. +func (a Agent) UploadChunk(arg0 UploadChunkArgs) (*UploadChunkResult, error) { + var r0 UploadChunkResult + if err := a.a.Call( + a.canisterId, + "upload_chunk", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +type BitcoinAddress = string + +type BitcoinGetBalanceArgs struct { + Address BitcoinAddress `ic:"address" json:"address"` + Network BitcoinNetwork `ic:"network" json:"network"` + MinConfirmations *uint32 `ic:"min_confirmations,omitempty" json:"min_confirmations,omitempty"` +} + +type BitcoinGetBalanceQueryArgs struct { + Address BitcoinAddress `ic:"address" json:"address"` + Network BitcoinNetwork `ic:"network" json:"network"` + MinConfirmations *uint32 `ic:"min_confirmations,omitempty" json:"min_confirmations,omitempty"` +} + +type BitcoinGetBalanceQueryResult = Satoshi + +type BitcoinGetBalanceResult = Satoshi + +type BitcoinGetCurrentFeePercentilesArgs struct { + Network BitcoinNetwork `ic:"network" json:"network"` +} + +type BitcoinGetCurrentFeePercentilesResult = []MillisatoshiPerByte + +type BitcoinGetUtxosArgs struct { + Address BitcoinAddress `ic:"address" json:"address"` + Network BitcoinNetwork `ic:"network" json:"network"` + Filter *struct { + MinConfirmations *uint32 `ic:"min_confirmations,variant"` + Page *[]byte `ic:"page,variant"` + } `ic:"filter,omitempty" json:"filter,omitempty"` +} + +type BitcoinGetUtxosQueryArgs struct { + Address BitcoinAddress `ic:"address" json:"address"` + Network BitcoinNetwork `ic:"network" json:"network"` + Filter *struct { + MinConfirmations *uint32 `ic:"min_confirmations,variant"` + Page *[]byte `ic:"page,variant"` + } `ic:"filter,omitempty" json:"filter,omitempty"` +} + +type BitcoinGetUtxosQueryResult struct { + Utxos []Utxo `ic:"utxos" json:"utxos"` + TipBlockHash BlockHash `ic:"tip_block_hash" json:"tip_block_hash"` + TipHeight uint32 `ic:"tip_height" json:"tip_height"` + NextPage *[]byte `ic:"next_page,omitempty" json:"next_page,omitempty"` +} + +type BitcoinGetUtxosResult struct { + Utxos []Utxo `ic:"utxos" json:"utxos"` + TipBlockHash BlockHash `ic:"tip_block_hash" json:"tip_block_hash"` + TipHeight uint32 `ic:"tip_height" json:"tip_height"` + NextPage *[]byte `ic:"next_page,omitempty" json:"next_page,omitempty"` +} + +type BitcoinNetwork struct { + Mainnet *idl.Null `ic:"mainnet,variant"` + Testnet *idl.Null `ic:"testnet,variant"` +} + +type BitcoinSendTransactionArgs struct { + Transaction []byte `ic:"transaction" json:"transaction"` + Network BitcoinNetwork `ic:"network" json:"network"` +} + +type BlockHash = []byte + +type CanisterId = principal.Principal + +type CanisterInfoArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` + NumRequestedChanges *uint64 `ic:"num_requested_changes,omitempty" json:"num_requested_changes,omitempty"` +} + +type CanisterInfoResult struct { + TotalNumChanges uint64 `ic:"total_num_changes" json:"total_num_changes"` + RecentChanges []Change `ic:"recent_changes" json:"recent_changes"` + ModuleHash *[]byte `ic:"module_hash,omitempty" json:"module_hash,omitempty"` + Controllers []principal.Principal `ic:"controllers" json:"controllers"` +} + +type CanisterInstallMode struct { + Install *idl.Null `ic:"install,variant"` + Reinstall *idl.Null `ic:"reinstall,variant"` + Upgrade **struct { + SkipPreUpgrade *bool `ic:"skip_pre_upgrade,omitempty" json:"skip_pre_upgrade,omitempty"` + } `ic:"upgrade,variant"` +} + +type CanisterSettings struct { + Controllers *[]principal.Principal `ic:"controllers,omitempty" json:"controllers,omitempty"` + ComputeAllocation *idl.Nat `ic:"compute_allocation,omitempty" json:"compute_allocation,omitempty"` + MemoryAllocation *idl.Nat `ic:"memory_allocation,omitempty" json:"memory_allocation,omitempty"` + FreezingThreshold *idl.Nat `ic:"freezing_threshold,omitempty" json:"freezing_threshold,omitempty"` + ReservedCyclesLimit *idl.Nat `ic:"reserved_cycles_limit,omitempty" json:"reserved_cycles_limit,omitempty"` +} + +type CanisterStatusArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type CanisterStatusResult struct { + Status struct { + Running *idl.Null `ic:"running,variant"` + Stopping *idl.Null `ic:"stopping,variant"` + Stopped *idl.Null `ic:"stopped,variant"` + } `ic:"status" json:"status"` + Settings DefiniteCanisterSettings `ic:"settings" json:"settings"` + ModuleHash *[]byte `ic:"module_hash,omitempty" json:"module_hash,omitempty"` + MemorySize idl.Nat `ic:"memory_size" json:"memory_size"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + ReservedCycles idl.Nat `ic:"reserved_cycles" json:"reserved_cycles"` + IdleCyclesBurnedPerDay idl.Nat `ic:"idle_cycles_burned_per_day" json:"idle_cycles_burned_per_day"` +} + +type Change struct { + TimestampNanos uint64 `ic:"timestamp_nanos" json:"timestamp_nanos"` + CanisterVersion uint64 `ic:"canister_version" json:"canister_version"` + Origin ChangeOrigin `ic:"origin" json:"origin"` + Details ChangeDetails `ic:"details" json:"details"` +} + +type ChangeDetails struct { + Creation *struct { + Controllers []principal.Principal `ic:"controllers" json:"controllers"` + } `ic:"creation,variant"` + CodeUninstall *idl.Null `ic:"code_uninstall,variant"` + CodeDeployment *struct { + Mode struct { + Install *idl.Null `ic:"install,variant"` + Reinstall *idl.Null `ic:"reinstall,variant"` + Upgrade *idl.Null `ic:"upgrade,variant"` + } `ic:"mode" json:"mode"` + ModuleHash []byte `ic:"module_hash" json:"module_hash"` + } `ic:"code_deployment,variant"` + ControllersChange *struct { + Controllers []principal.Principal `ic:"controllers" json:"controllers"` + } `ic:"controllers_change,variant"` +} + +type ChangeOrigin struct { + FromUser *struct { + UserId principal.Principal `ic:"user_id" json:"user_id"` + } `ic:"from_user,variant"` + FromCanister *struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + CanisterVersion *uint64 `ic:"canister_version,omitempty" json:"canister_version,omitempty"` + } `ic:"from_canister,variant"` +} + +type ChunkHash struct { + Hash []byte `ic:"hash" json:"hash"` +} + +type ClearChunkStoreArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type CreateCanisterArgs struct { + Settings *CanisterSettings `ic:"settings,omitempty" json:"settings,omitempty"` + SenderCanisterVersion *uint64 `ic:"sender_canister_version,omitempty" json:"sender_canister_version,omitempty"` +} + +type CreateCanisterResult struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type DefiniteCanisterSettings struct { + Controllers []principal.Principal `ic:"controllers" json:"controllers"` + ComputeAllocation idl.Nat `ic:"compute_allocation" json:"compute_allocation"` + MemoryAllocation idl.Nat `ic:"memory_allocation" json:"memory_allocation"` + FreezingThreshold idl.Nat `ic:"freezing_threshold" json:"freezing_threshold"` + ReservedCyclesLimit idl.Nat `ic:"reserved_cycles_limit" json:"reserved_cycles_limit"` +} + +type DeleteCanisterArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type DepositCyclesArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type EcdsaCurve struct { + Secp256k1 *idl.Null `ic:"secp256k1,variant"` +} + +type EcdsaPublicKeyArgs struct { + CanisterId *CanisterId `ic:"canister_id,omitempty" json:"canister_id,omitempty"` + DerivationPath [][]byte `ic:"derivation_path" json:"derivation_path"` + KeyId struct { + Curve EcdsaCurve `ic:"curve" json:"curve"` + Name string `ic:"name" json:"name"` + } `ic:"key_id" json:"key_id"` +} + +type EcdsaPublicKeyResult struct { + PublicKey []byte `ic:"public_key" json:"public_key"` + ChainCode []byte `ic:"chain_code" json:"chain_code"` +} + +type HttpHeader struct { + Name string `ic:"name" json:"name"` + Value string `ic:"value" json:"value"` +} + +type HttpRequestArgs struct { + Url string `ic:"url" json:"url"` + MaxResponseBytes *uint64 `ic:"max_response_bytes,omitempty" json:"max_response_bytes,omitempty"` + Method struct { + Get *idl.Null `ic:"get,variant"` + Head *idl.Null `ic:"head,variant"` + Post *idl.Null `ic:"post,variant"` + } `ic:"method" json:"method"` + Headers []HttpHeader `ic:"headers" json:"headers"` + Body *[]byte `ic:"body,omitempty" json:"body,omitempty"` + Transform *struct { + Function struct { /* NOT SUPPORTED */ + } `ic:"function" json:"function"` + Context []byte `ic:"context" json:"context"` + } `ic:"transform,omitempty" json:"transform,omitempty"` +} + +type HttpRequestResult struct { + Status idl.Nat `ic:"status" json:"status"` + Headers []HttpHeader `ic:"headers" json:"headers"` + Body []byte `ic:"body" json:"body"` +} + +type InstallChunkedCodeArgs struct { + Mode CanisterInstallMode `ic:"mode" json:"mode"` + TargetCanister CanisterId `ic:"target_canister" json:"target_canister"` + StoreCanister *CanisterId `ic:"store_canister,omitempty" json:"store_canister,omitempty"` + ChunkHashesList []ChunkHash `ic:"chunk_hashes_list" json:"chunk_hashes_list"` + WasmModuleHash []byte `ic:"wasm_module_hash" json:"wasm_module_hash"` + Arg []byte `ic:"arg" json:"arg"` + SenderCanisterVersion *uint64 `ic:"sender_canister_version,omitempty" json:"sender_canister_version,omitempty"` +} + +type InstallCodeArgs struct { + Mode CanisterInstallMode `ic:"mode" json:"mode"` + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` + WasmModule WasmModule `ic:"wasm_module" json:"wasm_module"` + Arg []byte `ic:"arg" json:"arg"` + SenderCanisterVersion *uint64 `ic:"sender_canister_version,omitempty" json:"sender_canister_version,omitempty"` +} + +type MillisatoshiPerByte = uint64 + +type NodeMetrics struct { + NodeId principal.Principal `ic:"node_id" json:"node_id"` + NumBlocksTotal uint64 `ic:"num_blocks_total" json:"num_blocks_total"` + NumBlockFailuresTotal uint64 `ic:"num_block_failures_total" json:"num_block_failures_total"` +} + +type NodeMetricsHistoryArgs struct { + SubnetId principal.Principal `ic:"subnet_id" json:"subnet_id"` + StartAtTimestampNanos uint64 `ic:"start_at_timestamp_nanos" json:"start_at_timestamp_nanos"` +} + +type NodeMetricsHistoryResult = []struct { + TimestampNanos uint64 `ic:"timestamp_nanos" json:"timestamp_nanos"` + NodeMetrics []NodeMetrics `ic:"node_metrics" json:"node_metrics"` +} + +type Outpoint struct { + Txid []byte `ic:"txid" json:"txid"` + Vout uint32 `ic:"vout" json:"vout"` +} + +type ProvisionalCreateCanisterWithCyclesArgs struct { + Amount *idl.Nat `ic:"amount,omitempty" json:"amount,omitempty"` + Settings *CanisterSettings `ic:"settings,omitempty" json:"settings,omitempty"` + SpecifiedId *CanisterId `ic:"specified_id,omitempty" json:"specified_id,omitempty"` + SenderCanisterVersion *uint64 `ic:"sender_canister_version,omitempty" json:"sender_canister_version,omitempty"` +} + +type ProvisionalCreateCanisterWithCyclesResult struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type ProvisionalTopUpCanisterArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` + Amount idl.Nat `ic:"amount" json:"amount"` +} + +type RawRandResult = []byte + +type Satoshi = uint64 + +type SignWithEcdsaArgs struct { + MessageHash []byte `ic:"message_hash" json:"message_hash"` + DerivationPath [][]byte `ic:"derivation_path" json:"derivation_path"` + KeyId struct { + Curve EcdsaCurve `ic:"curve" json:"curve"` + Name string `ic:"name" json:"name"` + } `ic:"key_id" json:"key_id"` +} + +type SignWithEcdsaResult struct { + Signature []byte `ic:"signature" json:"signature"` +} + +type StartCanisterArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type StopCanisterArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type StoredChunksArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` +} + +type StoredChunksResult = []ChunkHash + +type UninstallCodeArgs struct { + CanisterId CanisterId `ic:"canister_id" json:"canister_id"` + SenderCanisterVersion *uint64 `ic:"sender_canister_version,omitempty" json:"sender_canister_version,omitempty"` +} + +type UpdateSettingsArgs struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + Settings CanisterSettings `ic:"settings" json:"settings"` + SenderCanisterVersion *uint64 `ic:"sender_canister_version,omitempty" json:"sender_canister_version,omitempty"` +} + +type UploadChunkArgs struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + Chunk []byte `ic:"chunk" json:"chunk"` +} + +type UploadChunkResult = ChunkHash + +type Utxo struct { + Outpoint Outpoint `ic:"outpoint" json:"outpoint"` + Value Satoshi `ic:"value" json:"value"` + Height uint32 `ic:"height" json:"height"` +} + +type WasmModule = []byte diff --git a/ic/ic/agent_test.go b/ic/ic/agent_test.go new file mode 100755 index 0000000..c7dbf66 --- /dev/null +++ b/ic/ic/agent_test.go @@ -0,0 +1,860 @@ +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +package ic_test + +import ( + "github.com/aviate-labs/agent-go" + "github.com/aviate-labs/agent-go/candid/idl" + "github.com/aviate-labs/agent-go/mock" + "github.com/aviate-labs/agent-go/principal" + "net/http/httptest" + "net/url" + "testing" + + "github.com/aviate-labs/agent-go/ic/ic" +) + +// Test_BitcoinGetBalance tests the "bitcoin_get_balance" method on the "ic" canister. +func Test_BitcoinGetBalance(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "bitcoin_get_balance", + Arguments: []any{new(ic.BitcoinGetBalanceArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(ic.Satoshi)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.BitcoinGetBalanceArgs{ + *new(string), + ic.BitcoinNetwork{ + Mainnet: new(idl.Null), + }, + *new(*uint32), + } + if _, err := a.BitcoinGetBalance(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_BitcoinGetBalanceQuery tests the "bitcoin_get_balance_query" method on the "ic" canister. +func Test_BitcoinGetBalanceQuery(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "bitcoin_get_balance_query", + Arguments: []any{new(ic.BitcoinGetBalanceQueryArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(ic.Satoshi)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.BitcoinGetBalanceQueryArgs{ + *new(string), + ic.BitcoinNetwork{ + Mainnet: new(idl.Null), + }, + *new(*uint32), + } + if _, err := a.BitcoinGetBalanceQuery(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_BitcoinGetCurrentFeePercentiles tests the "bitcoin_get_current_fee_percentiles" method on the "ic" canister. +func Test_BitcoinGetCurrentFeePercentiles(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "bitcoin_get_current_fee_percentiles", + Arguments: []any{new(ic.BitcoinGetCurrentFeePercentilesArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new([]ic.MillisatoshiPerByte)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.BitcoinGetCurrentFeePercentilesArgs{ + ic.BitcoinNetwork{ + Mainnet: new(idl.Null), + }, + } + if _, err := a.BitcoinGetCurrentFeePercentiles(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_BitcoinGetUtxos tests the "bitcoin_get_utxos" method on the "ic" canister. +func Test_BitcoinGetUtxos(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "bitcoin_get_utxos", + Arguments: []any{new(ic.BitcoinGetUtxosArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.BitcoinGetUtxosResult{ + []ic.Utxo{{ + ic.Outpoint{ + *new([]byte), + *new(uint32), + }, + *new(uint64), + *new(uint32), + }}, + *new([]byte), + *new(uint32), + *new(*[]byte), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.BitcoinGetUtxosArgs{ + *new(string), + ic.BitcoinNetwork{ + Mainnet: new(idl.Null), + }, + *new(*struct { + MinConfirmations *uint32 `ic:"min_confirmations,variant"` + Page *[]byte `ic:"page,variant"` + }), + } + if _, err := a.BitcoinGetUtxos(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_BitcoinGetUtxosQuery tests the "bitcoin_get_utxos_query" method on the "ic" canister. +func Test_BitcoinGetUtxosQuery(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "bitcoin_get_utxos_query", + Arguments: []any{new(ic.BitcoinGetUtxosQueryArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.BitcoinGetUtxosQueryResult{ + []ic.Utxo{{ + ic.Outpoint{ + *new([]byte), + *new(uint32), + }, + *new(uint64), + *new(uint32), + }}, + *new([]byte), + *new(uint32), + *new(*[]byte), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.BitcoinGetUtxosQueryArgs{ + *new(string), + ic.BitcoinNetwork{ + Mainnet: new(idl.Null), + }, + *new(*struct { + MinConfirmations *uint32 `ic:"min_confirmations,variant"` + Page *[]byte `ic:"page,variant"` + }), + } + if _, err := a.BitcoinGetUtxosQuery(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_BitcoinSendTransaction tests the "bitcoin_send_transaction" method on the "ic" canister. +func Test_BitcoinSendTransaction(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "bitcoin_send_transaction", + Arguments: []any{new(ic.BitcoinSendTransactionArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.BitcoinSendTransactionArgs{ + *new([]byte), + ic.BitcoinNetwork{ + Mainnet: new(idl.Null), + }, + } + if err := a.BitcoinSendTransaction(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_CanisterInfo tests the "canister_info" method on the "ic" canister. +func Test_CanisterInfo(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "canister_info", + Arguments: []any{new(ic.CanisterInfoArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.CanisterInfoResult{ + *new(uint64), + []ic.Change{{ + *new(uint64), + *new(uint64), + ic.ChangeOrigin{ + FromUser: idl.Ptr(struct { + UserId principal.Principal `ic:"user_id" json:"user_id"` + }{ + *new(principal.Principal), + }), + }, + ic.ChangeDetails{ + Creation: idl.Ptr(struct { + Controllers []principal.Principal `ic:"controllers" json:"controllers"` + }{ + []principal.Principal{*new(principal.Principal)}, + }), + }, + }}, + *new(*[]byte), + []principal.Principal{*new(principal.Principal)}, + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.CanisterInfoArgs{ + *new(principal.Principal), + *new(*uint64), + } + if _, err := a.CanisterInfo(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_CanisterStatus tests the "canister_status" method on the "ic" canister. +func Test_CanisterStatus(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "canister_status", + Arguments: []any{new(ic.CanisterStatusArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.CanisterStatusResult{ + struct { + Running *idl.Null `ic:"running,variant"` + Stopping *idl.Null `ic:"stopping,variant"` + Stopped *idl.Null `ic:"stopped,variant"` + }{ + Running: new(idl.Null), + }, + ic.DefiniteCanisterSettings{ + []principal.Principal{*new(principal.Principal)}, + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + }, + *new(*[]byte), + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.CanisterStatusArgs{ + *new(principal.Principal), + } + if _, err := a.CanisterStatus(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_ClearChunkStore tests the "clear_chunk_store" method on the "ic" canister. +func Test_ClearChunkStore(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "clear_chunk_store", + Arguments: []any{new(ic.ClearChunkStoreArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.ClearChunkStoreArgs{ + *new(principal.Principal), + } + if err := a.ClearChunkStore(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_CreateCanister tests the "create_canister" method on the "ic" canister. +func Test_CreateCanister(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "create_canister", + Arguments: []any{new(ic.CreateCanisterArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.CreateCanisterResult{ + *new(principal.Principal), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.CreateCanisterArgs{ + *new(*ic.CanisterSettings), + *new(*uint64), + } + if _, err := a.CreateCanister(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_DeleteCanister tests the "delete_canister" method on the "ic" canister. +func Test_DeleteCanister(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "delete_canister", + Arguments: []any{new(ic.DeleteCanisterArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.DeleteCanisterArgs{ + *new(principal.Principal), + } + if err := a.DeleteCanister(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_DepositCycles tests the "deposit_cycles" method on the "ic" canister. +func Test_DepositCycles(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "deposit_cycles", + Arguments: []any{new(ic.DepositCyclesArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.DepositCyclesArgs{ + *new(principal.Principal), + } + if err := a.DepositCycles(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_EcdsaPublicKey tests the "ecdsa_public_key" method on the "ic" canister. +func Test_EcdsaPublicKey(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "ecdsa_public_key", + Arguments: []any{new(ic.EcdsaPublicKeyArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.EcdsaPublicKeyResult{ + *new([]byte), + *new([]byte), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.EcdsaPublicKeyArgs{ + *new(*ic.CanisterId), + [][]byte{*new([]byte)}, + struct { + Curve ic.EcdsaCurve `ic:"curve" json:"curve"` + Name string `ic:"name" json:"name"` + }{ + ic.EcdsaCurve{ + Secp256k1: new(idl.Null), + }, + *new(string), + }, + } + if _, err := a.EcdsaPublicKey(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_HttpRequest tests the "http_request" method on the "ic" canister. +func Test_HttpRequest(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "http_request", + Arguments: []any{new(ic.HttpRequestArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.HttpRequestResult{ + idl.NewNat(uint(0)), + []ic.HttpHeader{{ + *new(string), + *new(string), + }}, + *new([]byte), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.HttpRequestArgs{ + *new(string), + *new(*uint64), + struct { + Get *idl.Null `ic:"get,variant"` + Head *idl.Null `ic:"head,variant"` + Post *idl.Null `ic:"post,variant"` + }{ + Get: new(idl.Null), + }, + []ic.HttpHeader{{ + *new(string), + *new(string), + }}, + *new(*[]byte), + *new(*struct { + Function struct { /* NOT SUPPORTED */ + } `ic:"function" json:"function"` + Context []byte `ic:"context" json:"context"` + }), + } + if _, err := a.HttpRequest(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_InstallChunkedCode tests the "install_chunked_code" method on the "ic" canister. +func Test_InstallChunkedCode(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "install_chunked_code", + Arguments: []any{new(ic.InstallChunkedCodeArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.InstallChunkedCodeArgs{ + ic.CanisterInstallMode{ + Install: new(idl.Null), + }, + *new(principal.Principal), + *new(*ic.CanisterId), + []ic.ChunkHash{{ + *new([]byte), + }}, + *new([]byte), + *new([]byte), + *new(*uint64), + } + if err := a.InstallChunkedCode(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_InstallCode tests the "install_code" method on the "ic" canister. +func Test_InstallCode(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "install_code", + Arguments: []any{new(ic.InstallCodeArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.InstallCodeArgs{ + ic.CanisterInstallMode{ + Install: new(idl.Null), + }, + *new(principal.Principal), + *new([]byte), + *new([]byte), + *new(*uint64), + } + if err := a.InstallCode(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_NodeMetricsHistory tests the "node_metrics_history" method on the "ic" canister. +func Test_NodeMetricsHistory(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "node_metrics_history", + Arguments: []any{new(ic.NodeMetricsHistoryArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new([]struct { + TimestampNanos uint64 `ic:"timestamp_nanos" json:"timestamp_nanos"` + NodeMetrics []ic.NodeMetrics `ic:"node_metrics" json:"node_metrics"` + })}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.NodeMetricsHistoryArgs{ + *new(principal.Principal), + *new(uint64), + } + if _, err := a.NodeMetricsHistory(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_ProvisionalCreateCanisterWithCycles tests the "provisional_create_canister_with_cycles" method on the "ic" canister. +func Test_ProvisionalCreateCanisterWithCycles(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "provisional_create_canister_with_cycles", + Arguments: []any{new(ic.ProvisionalCreateCanisterWithCyclesArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.ProvisionalCreateCanisterWithCyclesResult{ + *new(principal.Principal), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.ProvisionalCreateCanisterWithCyclesArgs{ + *new(*idl.Nat), + *new(*ic.CanisterSettings), + *new(*ic.CanisterId), + *new(*uint64), + } + if _, err := a.ProvisionalCreateCanisterWithCycles(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_ProvisionalTopUpCanister tests the "provisional_top_up_canister" method on the "ic" canister. +func Test_ProvisionalTopUpCanister(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "provisional_top_up_canister", + Arguments: []any{new(ic.ProvisionalTopUpCanisterArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.ProvisionalTopUpCanisterArgs{ + *new(principal.Principal), + idl.NewNat(uint(0)), + } + if err := a.ProvisionalTopUpCanister(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_RawRand tests the "raw_rand" method on the "ic" canister. +func Test_RawRand(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "raw_rand", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new([]byte)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.RawRand(); err != nil { + t.Fatal(err) + } + +} + +// Test_SignWithEcdsa tests the "sign_with_ecdsa" method on the "ic" canister. +func Test_SignWithEcdsa(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "sign_with_ecdsa", + Arguments: []any{new(ic.SignWithEcdsaArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{ic.SignWithEcdsaResult{ + *new([]byte), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.SignWithEcdsaArgs{ + *new([]byte), + [][]byte{*new([]byte)}, + struct { + Curve ic.EcdsaCurve `ic:"curve" json:"curve"` + Name string `ic:"name" json:"name"` + }{ + ic.EcdsaCurve{ + Secp256k1: new(idl.Null), + }, + *new(string), + }, + } + if _, err := a.SignWithEcdsa(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_StartCanister tests the "start_canister" method on the "ic" canister. +func Test_StartCanister(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "start_canister", + Arguments: []any{new(ic.StartCanisterArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.StartCanisterArgs{ + *new(principal.Principal), + } + if err := a.StartCanister(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_StopCanister tests the "stop_canister" method on the "ic" canister. +func Test_StopCanister(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "stop_canister", + Arguments: []any{new(ic.StopCanisterArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.StopCanisterArgs{ + *new(principal.Principal), + } + if err := a.StopCanister(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_StoredChunks tests the "stored_chunks" method on the "ic" canister. +func Test_StoredChunks(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "stored_chunks", + Arguments: []any{new(ic.StoredChunksArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new([]ic.ChunkHash)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.StoredChunksArgs{ + *new(principal.Principal), + } + if _, err := a.StoredChunks(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_UninstallCode tests the "uninstall_code" method on the "ic" canister. +func Test_UninstallCode(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "uninstall_code", + Arguments: []any{new(ic.UninstallCodeArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.UninstallCodeArgs{ + *new(principal.Principal), + *new(*uint64), + } + if err := a.UninstallCode(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_UpdateSettings tests the "update_settings" method on the "ic" canister. +func Test_UpdateSettings(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "update_settings", + Arguments: []any{new(ic.UpdateSettingsArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.UpdateSettingsArgs{ + *new(principal.Principal), + ic.CanisterSettings{ + *new(*[]principal.Principal), + *new(*idl.Nat), + *new(*idl.Nat), + *new(*idl.Nat), + *new(*idl.Nat), + }, + *new(*uint64), + } + if err := a.UpdateSettings(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_UploadChunk tests the "upload_chunk" method on the "ic" canister. +func Test_UploadChunk(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "upload_chunk", + Arguments: []any{new(ic.UploadChunkArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(ic.ChunkHash)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = ic.UploadChunkArgs{ + *new(principal.Principal), + *new([]byte), + } + if _, err := a.UploadChunk(a0); err != nil { + t.Fatal(err) + } + +} + +// newAgent creates a new agent with the given (mock) methods. +// Runs a mock replica in the background. +func newAgent(methods []mock.Method) (*ic.Agent, error) { + replica := mock.NewReplica() + canisterId := principal.Principal{Raw: []byte("ic")} + replica.AddCanister(canisterId, methods) + s := httptest.NewServer(replica) + u, _ := url.Parse(s.URL) + a, err := ic.NewAgent(canisterId, agent.Config{ + ClientConfig: &agent.ClientConfig{Host: u}, + FetchRootKey: true, + }) + if err != nil { + return nil, err + } + return a, nil +} diff --git a/ic/ic/types.mo b/ic/ic/types.mo new file mode 100755 index 0000000..26e717b --- /dev/null +++ b/ic/ic/types.mo @@ -0,0 +1,64 @@ +// Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. +module T { + public type CanisterId = Principal; + public type WasmModule = Blob; + public type CanisterSettings = { controllers : ?[Principal]; compute_allocation : ?Nat; memory_allocation : ?Nat; freezing_threshold : ?Nat; reserved_cycles_limit : ?Nat }; + public type DefiniteCanisterSettings = { controllers : [Principal]; compute_allocation : Nat; memory_allocation : Nat; freezing_threshold : Nat; reserved_cycles_limit : Nat }; + public type ChangeOrigin = { #from_user : { user_id : Principal }; #from_canister : { canister_id : Principal; canister_version : ?Nat64 } }; + public type ChangeDetails = { #creation : { controllers : [Principal] }; #code_uninstall; #code_deployment : { mode : { #install; #reinstall; #upgrade }; module_hash : Blob }; #controllers_change : { controllers : [Principal] } }; + public type Change = { timestamp_nanos : Nat64; canister_version : Nat64; origin : T.ChangeOrigin; details : T.ChangeDetails }; + public type ChunkHash = { hash : Blob }; + public type HttpHeader = { name : Text; value : Text }; + public type HttpRequestResult = { status : Nat; headers : [T.HttpHeader]; body : Blob }; + public type EcdsaCurve = { #secp256k1 }; + public type Satoshi = Nat64; + public type BitcoinNetwork = { #mainnet; #testnet }; + public type BitcoinAddress = Text; + public type BlockHash = Blob; + public type Outpoint = { txid : Blob; vout : Nat32 }; + public type Utxo = { outpoint : T.Outpoint; value : T.Satoshi; height : Nat32 }; + public type BitcoinGetUtxosArgs = { address : T.BitcoinAddress; network : T.BitcoinNetwork; filter : ?{ #min_confirmations : Nat32; #page : Blob } }; + public type BitcoinGetUtxosQueryArgs = { address : T.BitcoinAddress; network : T.BitcoinNetwork; filter : ?{ #min_confirmations : Nat32; #page : Blob } }; + public type BitcoinGetCurrentFeePercentilesArgs = { network : T.BitcoinNetwork }; + public type BitcoinGetUtxosResult = { utxos : [T.Utxo]; tip_block_hash : T.BlockHash; tip_height : Nat32; next_page : ?Blob }; + public type BitcoinGetUtxosQueryResult = { utxos : [T.Utxo]; tip_block_hash : T.BlockHash; tip_height : Nat32; next_page : ?Blob }; + public type BitcoinGetBalanceArgs = { address : T.BitcoinAddress; network : T.BitcoinNetwork; min_confirmations : ?Nat32 }; + public type BitcoinGetBalanceQueryArgs = { address : T.BitcoinAddress; network : T.BitcoinNetwork; min_confirmations : ?Nat32 }; + public type BitcoinSendTransactionArgs = { transaction : Blob; network : T.BitcoinNetwork }; + public type MillisatoshiPerByte = Nat64; + public type NodeMetrics = { node_id : Principal; num_blocks_total : Nat64; num_block_failures_total : Nat64 }; + public type CreateCanisterArgs = { settings : ?T.CanisterSettings; sender_canister_version : ?Nat64 }; + public type CreateCanisterResult = { canister_id : T.CanisterId }; + public type UpdateSettingsArgs = { canister_id : Principal; settings : T.CanisterSettings; sender_canister_version : ?Nat64 }; + public type UploadChunkArgs = { canister_id : Principal; chunk : Blob }; + public type ClearChunkStoreArgs = { canister_id : T.CanisterId }; + public type StoredChunksArgs = { canister_id : T.CanisterId }; + public type CanisterInstallMode = { #install; #reinstall; #upgrade : ?{ skip_pre_upgrade : ?Bool } }; + public type InstallCodeArgs = { mode : T.CanisterInstallMode; canister_id : T.CanisterId; wasm_module : T.WasmModule; arg : Blob; sender_canister_version : ?Nat64 }; + public type InstallChunkedCodeArgs = { mode : T.CanisterInstallMode; target_canister : T.CanisterId; store_canister : ?T.CanisterId; chunk_hashes_list : [T.ChunkHash]; wasm_module_hash : Blob; arg : Blob; sender_canister_version : ?Nat64 }; + public type UninstallCodeArgs = { canister_id : T.CanisterId; sender_canister_version : ?Nat64 }; + public type StartCanisterArgs = { canister_id : T.CanisterId }; + public type StopCanisterArgs = { canister_id : T.CanisterId }; + public type CanisterStatusArgs = { canister_id : T.CanisterId }; + public type CanisterStatusResult = { status : { #running; #stopping; #stopped }; settings : T.DefiniteCanisterSettings; module_hash : ?Blob; memory_size : Nat; cycles : Nat; reserved_cycles : Nat; idle_cycles_burned_per_day : Nat }; + public type CanisterInfoArgs = { canister_id : T.CanisterId; num_requested_changes : ?Nat64 }; + public type CanisterInfoResult = { total_num_changes : Nat64; recent_changes : [T.Change]; module_hash : ?Blob; controllers : [Principal] }; + public type DeleteCanisterArgs = { canister_id : T.CanisterId }; + public type DepositCyclesArgs = { canister_id : T.CanisterId }; + public type HttpRequestArgs = { url : Text; max_response_bytes : ?Nat64; method : { #get; #head; #post }; headers : [T.HttpHeader]; body : ?Blob; transform : ?{ function : { /* func */ }; context : Blob } }; + public type EcdsaPublicKeyArgs = { canister_id : ?T.CanisterId; derivation_path : [Blob]; key_id : { curve : T.EcdsaCurve; name : Text } }; + public type EcdsaPublicKeyResult = { public_key : Blob; chain_code : Blob }; + public type SignWithEcdsaArgs = { message_hash : Blob; derivation_path : [Blob]; key_id : { curve : T.EcdsaCurve; name : Text } }; + public type SignWithEcdsaResult = { signature : Blob }; + public type NodeMetricsHistoryArgs = { subnet_id : Principal; start_at_timestamp_nanos : Nat64 }; + public type NodeMetricsHistoryResult = [{ timestamp_nanos : Nat64; node_metrics : [T.NodeMetrics] }]; + public type ProvisionalCreateCanisterWithCyclesArgs = { amount : ?Nat; settings : ?T.CanisterSettings; specified_id : ?T.CanisterId; sender_canister_version : ?Nat64 }; + public type ProvisionalCreateCanisterWithCyclesResult = { canister_id : T.CanisterId }; + public type ProvisionalTopUpCanisterArgs = { canister_id : T.CanisterId; amount : Nat }; + public type RawRandResult = Blob; + public type StoredChunksResult = [T.ChunkHash]; + public type UploadChunkResult = T.ChunkHash; + public type BitcoinGetBalanceResult = T.Satoshi; + public type BitcoinGetBalanceQueryResult = T.Satoshi; + public type BitcoinGetCurrentFeePercentilesResult = [T.MillisatoshiPerByte]; +}; diff --git a/ic/icparchive/actor.mo b/ic/icparchive/actor.mo index 9c55c8d..776c7c5 100755 --- a/ic/icparchive/actor.mo +++ b/ic/icparchive/actor.mo @@ -3,8 +3,11 @@ import T "types"; import { principalOfBlob } = "mo:⛔"; -actor class icparchive() : async actor {} { - public query func get_blocks(arg0 : T.GetBlocksArgs) : async (T.GetBlocksResult) { +actor class _icparchive() : async actor {} { + public query func get_blocks(_arg0 : T.GetBlocksArgs) : async (T.GetBlocksResult) { + (#Err(#BadFirstBlockIndex({ requested_index = 6197789885467376506; first_valid_index = 11539667703195591131 }))) + }; + public query func get_encoded_blocks(_arg0 : T.GetBlocksArgs) : async (T.GetEncodedBlocksResult) { (#Err(#BadFirstBlockIndex({ requested_index = 6197789885467376506; first_valid_index = 11539667703195591131 }))) }; } diff --git a/ic/icparchive/agent.go b/ic/icparchive/agent.go index bd450f8..4dfb4af 100755 --- a/ic/icparchive/agent.go +++ b/ic/icparchive/agent.go @@ -42,6 +42,20 @@ func (a Agent) GetBlocks(arg0 GetBlocksArgs) (*GetBlocksResult, error) { return &r0, nil } +// GetEncodedBlocks calls the "get_encoded_blocks" method on the "icparchive" canister. +func (a Agent) GetEncodedBlocks(arg0 GetBlocksArgs) (*GetEncodedBlocksResult, error) { + var r0 GetEncodedBlocksResult + if err := a.a.Query( + a.canisterId, + "get_encoded_blocks", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + type Block struct { ParentHash *[]byte `ic:"parent_hash,omitempty" json:"parent_hash,omitempty"` Transaction Transaction `ic:"transaction" json:"transaction"` @@ -75,6 +89,11 @@ type GetBlocksResult struct { Err *GetBlocksError `ic:"Err,variant"` } +type GetEncodedBlocksResult struct { + Ok *[][]byte `ic:"Ok,variant"` + Err *GetBlocksError `ic:"Err,variant"` +} + type Memo = uint64 type Operation struct { @@ -83,29 +102,26 @@ type Operation struct { Amount Tokens `ic:"amount" json:"amount"` } `ic:"Mint,variant"` Burn *struct { - From AccountIdentifier `ic:"from" json:"from"` - Amount Tokens `ic:"amount" json:"amount"` + From AccountIdentifier `ic:"from" json:"from"` + Spender *AccountIdentifier `ic:"spender,omitempty" json:"spender,omitempty"` + Amount Tokens `ic:"amount" json:"amount"` } `ic:"Burn,variant"` Transfer *struct { - From AccountIdentifier `ic:"from" json:"from"` - To AccountIdentifier `ic:"to" json:"to"` - Amount Tokens `ic:"amount" json:"amount"` - Fee Tokens `ic:"fee" json:"fee"` - } `ic:"Transfer,variant"` - Approve *struct { - From AccountIdentifier `ic:"from" json:"from"` - Spender AccountIdentifier `ic:"spender" json:"spender"` - AllowanceE8s idl.Int `ic:"allowance_e8s" json:"allowance_e8s"` - Fee Tokens `ic:"fee" json:"fee"` - ExpiresAt *Timestamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` - } `ic:"Approve,variant"` - TransferFrom *struct { From AccountIdentifier `ic:"from" json:"from"` To AccountIdentifier `ic:"to" json:"to"` - Spender AccountIdentifier `ic:"spender" json:"spender"` Amount Tokens `ic:"amount" json:"amount"` Fee Tokens `ic:"fee" json:"fee"` - } `ic:"TransferFrom,variant"` + Spender *[]uint8 `ic:"spender,omitempty" json:"spender,omitempty"` + } `ic:"Transfer,variant"` + Approve *struct { + From AccountIdentifier `ic:"from" json:"from"` + Spender AccountIdentifier `ic:"spender" json:"spender"` + AllowanceE8s idl.Int `ic:"allowance_e8s" json:"allowance_e8s"` + Allowance Tokens `ic:"allowance" json:"allowance"` + Fee Tokens `ic:"fee" json:"fee"` + ExpiresAt *Timestamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` + ExpectedAllowance *Tokens `ic:"expected_allowance,omitempty" json:"expected_allowance,omitempty"` + } `ic:"Approve,variant"` } type Timestamp struct { diff --git a/ic/icparchive/agent_test.go b/ic/icparchive/agent_test.go index 52b0b3d..d53011a 100644 --- a/ic/icparchive/agent_test.go +++ b/ic/icparchive/agent_test.go @@ -55,6 +55,33 @@ func Test_GetBlocks(t *testing.T) { } +// Test_GetEncodedBlocks tests the "get_encoded_blocks" method on the "icparchive" canister. +func Test_GetEncodedBlocks(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "get_encoded_blocks", + Arguments: []any{new(icparchive.GetBlocksArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{icparchive.GetEncodedBlocksResult{ + Ok: idl.Ptr([][]byte{*new([]byte)}), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icparchive.GetBlocksArgs{ + *new(uint64), + *new(uint64), + } + if _, err := a.GetEncodedBlocks(a0); err != nil { + t.Fatal(err) + } + +} + // newAgent creates a new agent with the given (mock) methods. // Runs a mock replica in the background. func newAgent(methods []mock.Method) (*icparchive.Agent, error) { diff --git a/ic/icparchive/types.mo b/ic/icparchive/types.mo index c521e5e..3628cb1 100755 --- a/ic/icparchive/types.mo +++ b/ic/icparchive/types.mo @@ -5,11 +5,12 @@ module T { public type AccountIdentifier = Blob; public type Tokens = { e8s : Nat64 }; public type Timestamp = { timestamp_nanos : Nat64 }; - public type Operation = { #Mint : { to : T.AccountIdentifier; amount : T.Tokens }; #Burn : { from : T.AccountIdentifier; amount : T.Tokens }; #Transfer : { from : T.AccountIdentifier; to : T.AccountIdentifier; amount : T.Tokens; fee : T.Tokens }; #Approve : { from : T.AccountIdentifier; spender : T.AccountIdentifier; allowance_e8s : Int; fee : T.Tokens; expires_at : ?T.Timestamp }; #TransferFrom : { from : T.AccountIdentifier; to : T.AccountIdentifier; spender : T.AccountIdentifier; amount : T.Tokens; fee : T.Tokens } }; + public type Operation = { #Mint : { to : T.AccountIdentifier; amount : T.Tokens }; #Burn : { from : T.AccountIdentifier; spender : ?T.AccountIdentifier; amount : T.Tokens }; #Transfer : { from : T.AccountIdentifier; to : T.AccountIdentifier; amount : T.Tokens; fee : T.Tokens; spender : ?[Nat8] }; #Approve : { from : T.AccountIdentifier; spender : T.AccountIdentifier; allowance_e8s : Int; allowance : T.Tokens; fee : T.Tokens; expires_at : ?T.Timestamp; expected_allowance : ?T.Tokens } }; public type Transaction = { memo : T.Memo; icrc1_memo : ?Blob; operation : ?T.Operation; created_at_time : T.Timestamp }; public type Block = { parent_hash : ?Blob; transaction : T.Transaction; timestamp : T.Timestamp }; public type GetBlocksArgs = { start : T.BlockIndex; length : Nat64 }; public type BlockRange = { blocks : [T.Block] }; public type GetBlocksError = { #BadFirstBlockIndex : { requested_index : T.BlockIndex; first_valid_index : T.BlockIndex }; #Other : { error_code : Nat64; error_message : Text } }; public type GetBlocksResult = { #Ok : T.BlockRange; #Err : T.GetBlocksError }; + public type GetEncodedBlocksResult = { #Ok : [Blob]; #Err : T.GetBlocksError }; }; diff --git a/ic/icpledger/actor.mo b/ic/icpledger/actor.mo index 335c78f..283e3ac 100755 --- a/ic/icpledger/actor.mo +++ b/ic/icpledger/actor.mo @@ -3,18 +3,24 @@ import T "types"; import { principalOfBlob } = "mo:⛔"; -actor class icpledger() : async actor {} { - public shared func transfer(arg0 : T.TransferArgs) : async (T.TransferResult) { +actor class _icpledger() : async actor {} { + public shared func transfer(_arg0 : T.TransferArgs) : async (T.TransferResult) { (#Err(#TxCreatedInFuture(()))) }; - public query func account_balance(arg0 : T.AccountBalanceArgs) : async (T.Tokens) { + public query func account_balance(_arg0 : T.AccountBalanceArgs) : async (T.Tokens) { ({ e8s = 6844078342166154913 }) }; - public query func transfer_fee(arg0 : T.TransferFeeArg) : async (T.TransferFee) { + public query func account_identifier(_arg0 : T.Account) : async (T.AccountIdentifier) { + ("xA10EC29FFD0CFB84891BC5734DC8A7DBD3D42B2C9D0A8FBBF49C31A6ECCAD503") + }; + public query func transfer_fee(_arg0 : T.TransferFeeArg) : async (T.TransferFee) { ({ transfer_fee = { e8s = 6844078342166154913 } }) }; - public query func query_blocks(arg0 : T.GetBlocksArgs) : async (T.QueryBlocksResponse) { - ({ chain_length = 6844078342166154913; certificate = ?"x84891BC5734DC8A7DBD3D42B2C9D0A8FBBF49C31A6ECCAD50322C04AE239219A"; blocks = [ { parent_hash = ?"x267840FA60A5160796052355DC613B3B6DD17D37E39432DAB2AB61070029151D"; transaction = { memo = 11508387437776522631; icrc1_memo = ?"x15D9B71F910AE4978C6001D6EBE96441FB2F2AC1E3F491B5AD85106B4D49CAAB"; operation = ?#Burn({ from = "xF8E011AAEE68D2270B08A64D94AE3AF0629EF547A02033FD611622DAB7C219DE"; amount = { e8s = 9640862273893842221 } }); created_at_time = { timestamp_nanos = 18434941167457045861 } }; timestamp = { timestamp_nanos = 17936735417084933145 } }, { parent_hash = ?"x0F380883A19D18A66069A4DB047004E9322EFCBF4A88CD79FDA4E21739AFDF90"; transaction = { memo = 3376834384587756782; icrc1_memo = ?"x545EE2B2142EB1A745A54BC94D2210536F44E142BA3842C40F699A300C037EAE"; operation = ?#Transfer({ from = "x2F856182D3B2EEDA50CC652B61D03D35374C19FD70685A626B0BE87B14E747B5"; to = "xBFD21F5B02A9AE32607D4F702056FB42F474E2D79096BB978CE3E215F5D16941"; amount = { e8s = 2337095702201755982 }; fee = { e8s = 8119966841819193775 } }); created_at_time = { timestamp_nanos = 14630522076889513897 } }; timestamp = { timestamp_nanos = 10234017389260060020 } }, { parent_hash = ?"x7F98C824FDA6E0DA1333D8621433A7F294C20BD614EBE11CC8CA2E8861E55E80"; transaction = { memo = 15846245038892287776; icrc1_memo = ?"xE2C6C57D0E4E5BC337B01396134D52E7E0CEF8A723CB9511450F3D57D9502E93"; operation = ?#Burn({ from = "xA277B665A7186D600DB1BE3907053ADA327550CC72BE69A0039ED288EA325359"; amount = { e8s = 13388315825435817461 } }); created_at_time = { timestamp_nanos = 1037580399648321749 } }; timestamp = { timestamp_nanos = 8765815739915276449 } } ]; first_block_index = 8774201989248131967; archived_blocks = [ { start = 9990291550900519784; length = 15814546617447143983; callback = { /* func */ } }, { start = 10525394844609216418; length = 13653777742181055018; callback = { /* func */ } }, { start = 5260480757802142243; length = 6532771774582539980; callback = { /* func */ } }, { start = 16823501307558194871; length = 4710247719163020692; callback = { /* func */ } }, { start = 743139622545088781; length = 1137136953581248725; callback = { /* func */ } } ] }) + public query func query_blocks(_arg0 : T.GetBlocksArgs) : async (T.QueryBlocksResponse) { + ({ chain_length = 6844078342166154913; certificate = ?"x84891BC5734DC8A7DBD3D42B2C9D0A8FBBF49C31A6ECCAD50322C04AE239219A"; blocks = [ { parent_hash = ?"x267840FA60A5160796052355DC613B3B6DD17D37E39432DAB2AB61070029151D"; transaction = { memo = 11508387437776522631; icrc1_memo = ?"x15D9B71F910AE4978C6001D6EBE96441FB2F2AC1E3F491B5AD85106B4D49CAAB"; operation = ?#Transfer({ from = "xF8E011AAEE68D2270B08A64D94AE3AF0629EF547A02033FD611622DAB7C219DE"; to = "x2D3DE89B2839CB658D80BD5111D619F48335D415EC0F380883A19D18A66069A4"; amount = { e8s = 4200380692304161028 }; fee = { e8s = 6059561021905423752 }; spender = ?[ 107, 120, 9 ] }); created_at_time = { timestamp_nanos = 8771396759540683536 } }; timestamp = { timestamp_nanos = 15217832916911669816 } }, { parent_hash = ?"x0C037EAEA22E01616AEEF852F0E82F856182D3B2EEDA50CC652B61D03D35374C"; transaction = { memo = 4070101824003267176; icrc1_memo = ?"x14E747B5FE200DBFD21F5B02A9AE32607D4F702056FB42F474E2D79096BB978C"; operation = ?#Burn({ from = "x4EE9D39F28086FAF61953AD2EAAFA97F8227500E0A743504E89788067F98C824"; spender = ?"xDA1333D8621433A7F294C20BD614EBE11CC8CA2E8861E55E80E9665D2087F8E6"; amount = { e8s = 1466851927785850594 } }); created_at_time = { timestamp_nanos = 14865559480316213187 } }; timestamp = { timestamp_nanos = 9017235565990438738 } }, { parent_hash = ?"xCB9511450F3D57D9502E93C887111564A06B691F5CA277B665A7186D600DB1BE"; transaction = { memo = 8895396859945867834; icrc1_memo = ?"xBE69A0039ED288EA3253592132AAF5B5D7134FDACCD530F24AE03966A1902DE0"; operation = ?#Approve({ from = "xAFC7FE45CD3970680303163CA5A42FDACA085C8E78A2FFA861D8B6112A3AD604"; spender = "x230A93C460FB00CCC6B01E5111A9B76E53F34D15799445CE3858295E0D6151A4"; allowance_e8s = 1137136953581248725; allowance = { e8s = 97406067914984320 }; fee = { e8s = 1968901117472609631 }; expires_at = ?{ timestamp_nanos = 16933899834649614941 }; expected_allowance = ?{ e8s = 9483663234984890706 } }); created_at_time = { timestamp_nanos = 10696245065444303678 } }; timestamp = { timestamp_nanos = 11131148948638734196 } } ]; first_block_index = 1770011220686955968; archived_blocks = [ { start = 2737438243966959150; length = 13531591559510253363; callback = { /* func */ } }, { start = 656934166386055698; length = 17781636316119954112; callback = { /* func */ } }, { start = 787507188863736678; length = 3342374177704650595; callback = { /* func */ } }, { start = 7357984375683813692; length = 9850727841105441469; callback = { /* func */ } }, { start = 18048247332320202900; length = 3626821402128685393; callback = { /* func */ } } ] }) + }; + public query func query_encoded_blocks(_arg0 : T.GetBlocksArgs) : async (T.QueryEncodedBlocksResponse) { + ({ certificate = ?"xA10EC29FFD0CFB84891BC5734DC8A7DBD3D42B2C9D0A8FBBF49C31A6ECCAD503"; blocks = [ "x8131F8664185C2267840FA60A5160796052355DC613B3B6DD17D37E39432DAB2", "x0029151DF0511187CD3C8E6601B615D9B71F910AE4978C6001D6EBE96441FB2F", "xF491B5AD85106B4D49CAAB5568811A2E80764917A3F8E011AAEE68D2270B08A6", "x3AF0629EF547A02033FD611622DAB7C219DE5142FB2D3DE89B2839CB658D80BD" ]; chain_length = 17936735417084933145; first_block_index = 15571369028647139343; archived_blocks = [ ] }) }; public query func symbol() : async ({ symbol : Text }) { ({ symbol = "6844078342166154913" }) @@ -28,4 +34,49 @@ actor class icpledger() : async actor {} { public query func archives() : async (T.Archives) { ({ archives = [ { canister_id = principalOfBlob("x84891BC5734DC8A7DBD3D42B2C9D0A8FBBF49C31A6ECCAD50322C04AE239219A") }, { canister_id = principalOfBlob("x8131F8664185C2267840FA60A5160796052355DC613B3B6DD17D37E39432DAB2") }, { canister_id = principalOfBlob("x0029151DF0511187CD3C8E6601B615D9B71F910AE4978C6001D6EBE96441FB2F") } ] }) }; + public shared func send_dfx(_arg0 : T.SendArgs) : async (T.BlockIndex) { + (6844078342166154913) + }; + public query func account_balance_dfx(_arg0 : T.AccountBalanceArgsDfx) : async (T.Tokens) { + ({ e8s = 6844078342166154913 }) + }; + public query func icrc1_name() : async (Text) { + ("6844078342166154913") + }; + public query func icrc1_symbol() : async (Text) { + ("6844078342166154913") + }; + public query func icrc1_decimals() : async (Nat8) { + (118) + }; + public query func icrc1_metadata() : async ([(Text, T.Value)]) { + ([ ( "7478312340872202628", #Blob("x0A8FBBF49C31A6ECCAD50322C04AE239219AAEF2E58131F8664185C2267840FA") ), ( "27545330958833159", #Blob("x9432DAB2AB61070029151DF0511187CD3C8E6601B615D9B71F910AE4978C6001") ), ( "14043280450009121124", #Nat(6521608452572858701) ) ]) + }; + public query func icrc1_total_supply() : async (T.Icrc1Tokens) { + (6844078342166154913) + }; + public query func icrc1_fee() : async (T.Icrc1Tokens) { + (6844078342166154913) + }; + public query func icrc1_minting_account() : async (?T.Account) { + (?{ owner = principalOfBlob("xA10EC29FFD0CFB84891BC5734DC8A7DBD3D42B2C9D0A8FBBF49C31A6ECCAD503"); subaccount = ?"xE239219AAEF2E58131F8664185C2267840FA60A5160796052355DC613B3B6DD1" }) + }; + public query func icrc1_balance_of(_arg0 : T.Account) : async (T.Icrc1Tokens) { + (6844078342166154913) + }; + public shared func icrc1_transfer(_arg0 : T.TransferArg) : async (T.Icrc1TransferResult) { + (#Err(#CreatedInFuture({ ledger_time = 3070659087702416295 }))) + }; + public query func icrc1_supported_standards() : async ([{ name : Text; url : Text }]) { + ([ { name = "7478312340872202628"; url = "3070659087702416295" }, { name = "16475910836972130058"; url = "14216386426074155756" }, { name = "8999866262093904354"; url = "270925443542561153" } ]) + }; + public shared func icrc2_approve(_arg0 : T.ApproveArgs) : async (T.ApproveResult) { + (#Err(#TooOld)) + }; + public query func icrc2_allowance(_arg0 : T.AllowanceArgs) : async (T.Allowance) { + ({ allowance = 6844078342166154913; expires_at = ?7478312340872202628 }) + }; + public shared func icrc2_transfer_from(_arg0 : T.TransferFromArgs) : async (T.TransferFromResult) { + (#Err(#TooOld)) + }; } diff --git a/ic/icpledger/agent.go b/ic/icpledger/agent.go index 077f2de..a0f6e23 100755 --- a/ic/icpledger/agent.go +++ b/ic/icpledger/agent.go @@ -8,10 +8,19 @@ import ( "github.com/aviate-labs/agent-go/principal" ) +type Account struct { + Owner principal.Principal `ic:"owner" json:"owner"` + Subaccount *SubAccount `ic:"subaccount,omitempty" json:"subaccount,omitempty"` +} + type AccountBalanceArgs struct { Account AccountIdentifier `ic:"account" json:"account"` } +type AccountBalanceArgsDfx struct { + Account TextAccountIdentifier `ic:"account" json:"account"` +} + type AccountIdentifier = []byte // Agent is a client for the "icpledger" canister. @@ -46,6 +55,34 @@ func (a Agent) AccountBalance(arg0 AccountBalanceArgs) (*Tokens, error) { return &r0, nil } +// AccountBalanceDfx calls the "account_balance_dfx" method on the "icpledger" canister. +func (a Agent) AccountBalanceDfx(arg0 AccountBalanceArgsDfx) (*Tokens, error) { + var r0 Tokens + if err := a.a.Query( + a.canisterId, + "account_balance_dfx", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// AccountIdentifier calls the "account_identifier" method on the "icpledger" canister. +func (a Agent) AccountIdentifier(arg0 Account) (*AccountIdentifier, error) { + var r0 AccountIdentifier + if err := a.a.Query( + a.canisterId, + "account_identifier", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + // Archives calls the "archives" method on the "icpledger" canister. func (a Agent) Archives() (*Archives, error) { var r0 Archives @@ -78,6 +115,200 @@ func (a Agent) Decimals() (*struct { return &r0, nil } +// Icrc1BalanceOf calls the "icrc1_balance_of" method on the "icpledger" canister. +func (a Agent) Icrc1BalanceOf(arg0 Account) (*Icrc1Tokens, error) { + var r0 Icrc1Tokens + if err := a.a.Query( + a.canisterId, + "icrc1_balance_of", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Decimals calls the "icrc1_decimals" method on the "icpledger" canister. +func (a Agent) Icrc1Decimals() (*uint8, error) { + var r0 uint8 + if err := a.a.Query( + a.canisterId, + "icrc1_decimals", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Fee calls the "icrc1_fee" method on the "icpledger" canister. +func (a Agent) Icrc1Fee() (*Icrc1Tokens, error) { + var r0 Icrc1Tokens + if err := a.a.Query( + a.canisterId, + "icrc1_fee", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Metadata calls the "icrc1_metadata" method on the "icpledger" canister. +func (a Agent) Icrc1Metadata() (*[]struct { + Field0 string `ic:"0" json:"0"` + Field1 Value `ic:"1" json:"1"` +}, error) { + var r0 []struct { + Field0 string `ic:"0" json:"0"` + Field1 Value `ic:"1" json:"1"` + } + if err := a.a.Query( + a.canisterId, + "icrc1_metadata", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1MintingAccount calls the "icrc1_minting_account" method on the "icpledger" canister. +func (a Agent) Icrc1MintingAccount() (**Account, error) { + var r0 *Account + if err := a.a.Query( + a.canisterId, + "icrc1_minting_account", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Name calls the "icrc1_name" method on the "icpledger" canister. +func (a Agent) Icrc1Name() (*string, error) { + var r0 string + if err := a.a.Query( + a.canisterId, + "icrc1_name", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1SupportedStandards calls the "icrc1_supported_standards" method on the "icpledger" canister. +func (a Agent) Icrc1SupportedStandards() (*[]struct { + Name string `ic:"name" json:"name"` + Url string `ic:"url" json:"url"` +}, error) { + var r0 []struct { + Name string `ic:"name" json:"name"` + Url string `ic:"url" json:"url"` + } + if err := a.a.Query( + a.canisterId, + "icrc1_supported_standards", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Symbol calls the "icrc1_symbol" method on the "icpledger" canister. +func (a Agent) Icrc1Symbol() (*string, error) { + var r0 string + if err := a.a.Query( + a.canisterId, + "icrc1_symbol", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1TotalSupply calls the "icrc1_total_supply" method on the "icpledger" canister. +func (a Agent) Icrc1TotalSupply() (*Icrc1Tokens, error) { + var r0 Icrc1Tokens + if err := a.a.Query( + a.canisterId, + "icrc1_total_supply", + []any{}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc1Transfer calls the "icrc1_transfer" method on the "icpledger" canister. +func (a Agent) Icrc1Transfer(arg0 TransferArg) (*Icrc1TransferResult, error) { + var r0 Icrc1TransferResult + if err := a.a.Call( + a.canisterId, + "icrc1_transfer", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc2Allowance calls the "icrc2_allowance" method on the "icpledger" canister. +func (a Agent) Icrc2Allowance(arg0 AllowanceArgs) (*Allowance, error) { + var r0 Allowance + if err := a.a.Query( + a.canisterId, + "icrc2_allowance", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc2Approve calls the "icrc2_approve" method on the "icpledger" canister. +func (a Agent) Icrc2Approve(arg0 ApproveArgs) (*ApproveResult, error) { + var r0 ApproveResult + if err := a.a.Call( + a.canisterId, + "icrc2_approve", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// Icrc2TransferFrom calls the "icrc2_transfer_from" method on the "icpledger" canister. +func (a Agent) Icrc2TransferFrom(arg0 TransferFromArgs) (*TransferFromResult, error) { + var r0 TransferFromResult + if err := a.a.Call( + a.canisterId, + "icrc2_transfer_from", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + // Name calls the "name" method on the "icpledger" canister. func (a Agent) Name() (*struct { Name string `ic:"name" json:"name"` @@ -110,6 +341,34 @@ func (a Agent) QueryBlocks(arg0 GetBlocksArgs) (*QueryBlocksResponse, error) { return &r0, nil } +// QueryEncodedBlocks calls the "query_encoded_blocks" method on the "icpledger" canister. +func (a Agent) QueryEncodedBlocks(arg0 GetBlocksArgs) (*QueryEncodedBlocksResponse, error) { + var r0 QueryEncodedBlocksResponse + if err := a.a.Query( + a.canisterId, + "query_encoded_blocks", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + +// SendDfx calls the "send_dfx" method on the "icpledger" canister. +func (a Agent) SendDfx(arg0 SendArgs) (*BlockIndex, error) { + var r0 BlockIndex + if err := a.a.Call( + a.canisterId, + "send_dfx", + []any{arg0}, + []any{&r0}, + ); err != nil { + return nil, err + } + return &r0, nil +} + // Symbol calls the "symbol" method on the "icpledger" canister. func (a Agent) Symbol() (*struct { Symbol string `ic:"symbol" json:"symbol"` @@ -156,10 +415,87 @@ func (a Agent) TransferFee(arg0 TransferFeeArg) (*TransferFee, error) { return &r0, nil } +type Allowance struct { + Allowance Icrc1Tokens `ic:"allowance" json:"allowance"` + ExpiresAt *Icrc1Timestamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` +} + +type AllowanceArgs struct { + Account Account `ic:"account" json:"account"` + Spender Account `ic:"spender" json:"spender"` +} + +type ApproveArgs struct { + FromSubaccount *SubAccount `ic:"from_subaccount,omitempty" json:"from_subaccount,omitempty"` + Spender Account `ic:"spender" json:"spender"` + Amount Icrc1Tokens `ic:"amount" json:"amount"` + ExpectedAllowance *Icrc1Tokens `ic:"expected_allowance,omitempty" json:"expected_allowance,omitempty"` + ExpiresAt *Icrc1Timestamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` + Fee *Icrc1Tokens `ic:"fee,omitempty" json:"fee,omitempty"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Icrc1Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` +} + +type ApproveError struct { + BadFee *struct { + ExpectedFee Icrc1Tokens `ic:"expected_fee" json:"expected_fee"` + } `ic:"BadFee,variant"` + InsufficientFunds *struct { + Balance Icrc1Tokens `ic:"balance" json:"balance"` + } `ic:"InsufficientFunds,variant"` + AllowanceChanged *struct { + CurrentAllowance Icrc1Tokens `ic:"current_allowance" json:"current_allowance"` + } `ic:"AllowanceChanged,variant"` + Expired *struct { + LedgerTime uint64 `ic:"ledger_time" json:"ledger_time"` + } `ic:"Expired,variant"` + TooOld *idl.Null `ic:"TooOld,variant"` + CreatedInFuture *struct { + LedgerTime uint64 `ic:"ledger_time" json:"ledger_time"` + } `ic:"CreatedInFuture,variant"` + Duplicate *struct { + DuplicateOf Icrc1BlockIndex `ic:"duplicate_of" json:"duplicate_of"` + } `ic:"Duplicate,variant"` + TemporarilyUnavailable *idl.Null `ic:"TemporarilyUnavailable,variant"` + GenericError *struct { + ErrorCode idl.Nat `ic:"error_code" json:"error_code"` + Message string `ic:"message" json:"message"` + } `ic:"GenericError,variant"` +} + +type ApproveResult struct { + Ok *Icrc1BlockIndex `ic:"Ok,variant"` + Err *ApproveError `ic:"Err,variant"` +} + type Archive struct { CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` } +type ArchiveOptions struct { + TriggerThreshold uint64 `ic:"trigger_threshold" json:"trigger_threshold"` + NumBlocksToArchive uint64 `ic:"num_blocks_to_archive" json:"num_blocks_to_archive"` + NodeMaxMemorySizeBytes *uint64 `ic:"node_max_memory_size_bytes,omitempty" json:"node_max_memory_size_bytes,omitempty"` + MaxMessageSizeBytes *uint64 `ic:"max_message_size_bytes,omitempty" json:"max_message_size_bytes,omitempty"` + ControllerId principal.Principal `ic:"controller_id" json:"controller_id"` + MoreControllerIds *[]principal.Principal `ic:"more_controller_ids,omitempty" json:"more_controller_ids,omitempty"` + CyclesForArchiveCreation *uint64 `ic:"cycles_for_archive_creation,omitempty" json:"cycles_for_archive_creation,omitempty"` + MaxTransactionsPerResponse *uint64 `ic:"max_transactions_per_response,omitempty" json:"max_transactions_per_response,omitempty"` +} + +type ArchivedBlocksRange struct { + Start BlockIndex `ic:"start" json:"start"` + Length uint64 `ic:"length" json:"length"` + Callback QueryArchiveFn `ic:"callback" json:"callback"` +} + +type ArchivedEncodedBlocksRange struct { + Callback struct { /* NOT SUPPORTED */ + } `ic:"callback" json:"callback"` + Start uint64 `ic:"start" json:"start"` + Length uint64 `ic:"length" json:"length"` +} + type Archives struct { Archives []Archive `ic:"archives" json:"archives"` } @@ -176,11 +512,79 @@ type BlockRange struct { Blocks []Block `ic:"blocks" json:"blocks"` } +type Duration struct { + Secs uint64 `ic:"secs" json:"secs"` + Nanos uint32 `ic:"nanos" json:"nanos"` +} + +type FeatureFlags struct { + Icrc2 bool `ic:"icrc2" json:"icrc2"` +} + type GetBlocksArgs struct { Start BlockIndex `ic:"start" json:"start"` Length uint64 `ic:"length" json:"length"` } +type Icrc1BlockIndex = idl.Nat + +type Icrc1Timestamp = uint64 + +type Icrc1Tokens = idl.Nat + +type Icrc1TransferError struct { + BadFee *struct { + ExpectedFee Icrc1Tokens `ic:"expected_fee" json:"expected_fee"` + } `ic:"BadFee,variant"` + BadBurn *struct { + MinBurnAmount Icrc1Tokens `ic:"min_burn_amount" json:"min_burn_amount"` + } `ic:"BadBurn,variant"` + InsufficientFunds *struct { + Balance Icrc1Tokens `ic:"balance" json:"balance"` + } `ic:"InsufficientFunds,variant"` + TooOld *idl.Null `ic:"TooOld,variant"` + CreatedInFuture *struct { + LedgerTime uint64 `ic:"ledger_time" json:"ledger_time"` + } `ic:"CreatedInFuture,variant"` + TemporarilyUnavailable *idl.Null `ic:"TemporarilyUnavailable,variant"` + Duplicate *struct { + DuplicateOf Icrc1BlockIndex `ic:"duplicate_of" json:"duplicate_of"` + } `ic:"Duplicate,variant"` + GenericError *struct { + ErrorCode idl.Nat `ic:"error_code" json:"error_code"` + Message string `ic:"message" json:"message"` + } `ic:"GenericError,variant"` +} + +type Icrc1TransferResult struct { + Ok *Icrc1BlockIndex `ic:"Ok,variant"` + Err *Icrc1TransferError `ic:"Err,variant"` +} + +type InitArgs struct { + MintingAccount TextAccountIdentifier `ic:"minting_account" json:"minting_account"` + Icrc1MintingAccount *Account `ic:"icrc1_minting_account,omitempty" json:"icrc1_minting_account,omitempty"` + InitialValues []struct { + Field0 TextAccountIdentifier `ic:"0" json:"0"` + Field1 Tokens `ic:"1" json:"1"` + } `ic:"initial_values" json:"initial_values"` + MaxMessageSizeBytes *uint64 `ic:"max_message_size_bytes,omitempty" json:"max_message_size_bytes,omitempty"` + TransactionWindow *Duration `ic:"transaction_window,omitempty" json:"transaction_window,omitempty"` + ArchiveOptions *ArchiveOptions `ic:"archive_options,omitempty" json:"archive_options,omitempty"` + SendWhitelist []principal.Principal `ic:"send_whitelist" json:"send_whitelist"` + TransferFee *Tokens `ic:"transfer_fee,omitempty" json:"transfer_fee,omitempty"` + TokenSymbol *string `ic:"token_symbol,omitempty" json:"token_symbol,omitempty"` + TokenName *string `ic:"token_name,omitempty" json:"token_name,omitempty"` + FeatureFlags *FeatureFlags `ic:"feature_flags,omitempty" json:"feature_flags,omitempty"` + MaximumNumberOfAccounts *uint64 `ic:"maximum_number_of_accounts,omitempty" json:"maximum_number_of_accounts,omitempty"` + AccountsOverflowTrimQuantity *uint64 `ic:"accounts_overflow_trim_quantity,omitempty" json:"accounts_overflow_trim_quantity,omitempty"` +} + +type LedgerCanisterPayload struct { + Init *InitArgs `ic:"Init,variant"` + Upgrade **UpgradeArgs `ic:"Upgrade,variant"` +} + type Memo = uint64 type Operation struct { @@ -189,29 +593,26 @@ type Operation struct { Amount Tokens `ic:"amount" json:"amount"` } `ic:"Mint,variant"` Burn *struct { - From AccountIdentifier `ic:"from" json:"from"` - Amount Tokens `ic:"amount" json:"amount"` + From AccountIdentifier `ic:"from" json:"from"` + Spender *AccountIdentifier `ic:"spender,omitempty" json:"spender,omitempty"` + Amount Tokens `ic:"amount" json:"amount"` } `ic:"Burn,variant"` Transfer *struct { - From AccountIdentifier `ic:"from" json:"from"` - To AccountIdentifier `ic:"to" json:"to"` - Amount Tokens `ic:"amount" json:"amount"` - Fee Tokens `ic:"fee" json:"fee"` - } `ic:"Transfer,variant"` - Approve *struct { - From AccountIdentifier `ic:"from" json:"from"` - Spender AccountIdentifier `ic:"spender" json:"spender"` - AllowanceE8s idl.Int `ic:"allowance_e8s" json:"allowance_e8s"` - Fee Tokens `ic:"fee" json:"fee"` - ExpiresAt *TimeStamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` - } `ic:"Approve,variant"` - TransferFrom *struct { From AccountIdentifier `ic:"from" json:"from"` To AccountIdentifier `ic:"to" json:"to"` - Spender AccountIdentifier `ic:"spender" json:"spender"` Amount Tokens `ic:"amount" json:"amount"` Fee Tokens `ic:"fee" json:"fee"` - } `ic:"TransferFrom,variant"` + Spender *[]uint8 `ic:"spender,omitempty" json:"spender,omitempty"` + } `ic:"Transfer,variant"` + Approve *struct { + From AccountIdentifier `ic:"from" json:"from"` + Spender AccountIdentifier `ic:"spender" json:"spender"` + AllowanceE8s idl.Int `ic:"allowance_e8s" json:"allowance_e8s"` + Allowance Tokens `ic:"allowance" json:"allowance"` + Fee Tokens `ic:"fee" json:"fee"` + ExpiresAt *TimeStamp `ic:"expires_at,omitempty" json:"expires_at,omitempty"` + ExpectedAllowance *Tokens `ic:"expected_allowance,omitempty" json:"expected_allowance,omitempty"` + } `ic:"Approve,variant"` } type QueryArchiveError struct { @@ -234,19 +635,34 @@ type QueryArchiveResult struct { } type QueryBlocksResponse struct { - ChainLength uint64 `ic:"chain_length" json:"chain_length"` - Certificate *[]byte `ic:"certificate,omitempty" json:"certificate,omitempty"` - Blocks []Block `ic:"blocks" json:"blocks"` - FirstBlockIndex BlockIndex `ic:"first_block_index" json:"first_block_index"` - ArchivedBlocks []struct { - Start BlockIndex `ic:"start" json:"start"` - Length uint64 `ic:"length" json:"length"` - Callback QueryArchiveFn `ic:"callback" json:"callback"` - } `ic:"archived_blocks" json:"archived_blocks"` + ChainLength uint64 `ic:"chain_length" json:"chain_length"` + Certificate *[]byte `ic:"certificate,omitempty" json:"certificate,omitempty"` + Blocks []Block `ic:"blocks" json:"blocks"` + FirstBlockIndex BlockIndex `ic:"first_block_index" json:"first_block_index"` + ArchivedBlocks []ArchivedBlocksRange `ic:"archived_blocks" json:"archived_blocks"` +} + +type QueryEncodedBlocksResponse struct { + Certificate *[]byte `ic:"certificate,omitempty" json:"certificate,omitempty"` + Blocks [][]byte `ic:"blocks" json:"blocks"` + ChainLength uint64 `ic:"chain_length" json:"chain_length"` + FirstBlockIndex uint64 `ic:"first_block_index" json:"first_block_index"` + ArchivedBlocks []ArchivedEncodedBlocksRange `ic:"archived_blocks" json:"archived_blocks"` +} + +type SendArgs struct { + Memo Memo `ic:"memo" json:"memo"` + Amount Tokens `ic:"amount" json:"amount"` + Fee Tokens `ic:"fee" json:"fee"` + FromSubaccount *SubAccount `ic:"from_subaccount,omitempty" json:"from_subaccount,omitempty"` + To TextAccountIdentifier `ic:"to" json:"to"` + CreatedAtTime *TimeStamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` } type SubAccount = []byte +type TextAccountIdentifier = string + type TimeStamp struct { TimestampNanos uint64 `ic:"timestamp_nanos" json:"timestamp_nanos"` } @@ -262,6 +678,15 @@ type Transaction struct { CreatedAtTime TimeStamp `ic:"created_at_time" json:"created_at_time"` } +type TransferArg struct { + FromSubaccount *SubAccount `ic:"from_subaccount,omitempty" json:"from_subaccount,omitempty"` + To Account `ic:"to" json:"to"` + Amount Icrc1Tokens `ic:"amount" json:"amount"` + Fee *Icrc1Tokens `ic:"fee,omitempty" json:"fee,omitempty"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Icrc1Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` +} + type TransferArgs struct { Memo Memo `ic:"memo" json:"memo"` Amount Tokens `ic:"amount" json:"amount"` @@ -294,7 +719,62 @@ type TransferFee struct { type TransferFeeArg struct { } +type TransferFromArgs struct { + SpenderSubaccount *SubAccount `ic:"spender_subaccount,omitempty" json:"spender_subaccount,omitempty"` + From Account `ic:"from" json:"from"` + To Account `ic:"to" json:"to"` + Amount Icrc1Tokens `ic:"amount" json:"amount"` + Fee *Icrc1Tokens `ic:"fee,omitempty" json:"fee,omitempty"` + Memo *[]byte `ic:"memo,omitempty" json:"memo,omitempty"` + CreatedAtTime *Icrc1Timestamp `ic:"created_at_time,omitempty" json:"created_at_time,omitempty"` +} + +type TransferFromError struct { + BadFee *struct { + ExpectedFee Icrc1Tokens `ic:"expected_fee" json:"expected_fee"` + } `ic:"BadFee,variant"` + BadBurn *struct { + MinBurnAmount Icrc1Tokens `ic:"min_burn_amount" json:"min_burn_amount"` + } `ic:"BadBurn,variant"` + InsufficientFunds *struct { + Balance Icrc1Tokens `ic:"balance" json:"balance"` + } `ic:"InsufficientFunds,variant"` + InsufficientAllowance *struct { + Allowance Icrc1Tokens `ic:"allowance" json:"allowance"` + } `ic:"InsufficientAllowance,variant"` + TooOld *idl.Null `ic:"TooOld,variant"` + CreatedInFuture *struct { + LedgerTime Icrc1Timestamp `ic:"ledger_time" json:"ledger_time"` + } `ic:"CreatedInFuture,variant"` + Duplicate *struct { + DuplicateOf Icrc1BlockIndex `ic:"duplicate_of" json:"duplicate_of"` + } `ic:"Duplicate,variant"` + TemporarilyUnavailable *idl.Null `ic:"TemporarilyUnavailable,variant"` + GenericError *struct { + ErrorCode idl.Nat `ic:"error_code" json:"error_code"` + Message string `ic:"message" json:"message"` + } `ic:"GenericError,variant"` +} + +type TransferFromResult struct { + Ok *Icrc1BlockIndex `ic:"Ok,variant"` + Err *TransferFromError `ic:"Err,variant"` +} + type TransferResult struct { Ok *BlockIndex `ic:"Ok,variant"` Err *TransferError `ic:"Err,variant"` } + +type UpgradeArgs struct { + MaximumNumberOfAccounts *uint64 `ic:"maximum_number_of_accounts,omitempty" json:"maximum_number_of_accounts,omitempty"` + Icrc1MintingAccount *Account `ic:"icrc1_minting_account,omitempty" json:"icrc1_minting_account,omitempty"` + FeatureFlags *FeatureFlags `ic:"feature_flags,omitempty" json:"feature_flags,omitempty"` +} + +type Value struct { + Nat *idl.Nat `ic:"Nat,variant"` + Int *idl.Int `ic:"Int,variant"` + Text *string `ic:"Text,variant"` + Blob *[]byte `ic:"Blob,variant"` +} diff --git a/ic/icpledger/agent_test.go b/ic/icpledger/agent_test.go index 25f1842..b5e16d8 100644 --- a/ic/icpledger/agent_test.go +++ b/ic/icpledger/agent_test.go @@ -3,7 +3,7 @@ package icpledger_test import ( "github.com/aviate-labs/agent-go" - + "github.com/aviate-labs/agent-go/candid/idl" "github.com/aviate-labs/agent-go/mock" "github.com/aviate-labs/agent-go/principal" "net/http/httptest" @@ -39,6 +39,57 @@ func Test_AccountBalance(t *testing.T) { } +// Test_AccountBalanceDfx tests the "account_balance_dfx" method on the "icpledger" canister. +func Test_AccountBalanceDfx(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "account_balance_dfx", + Arguments: []any{new(icpledger.AccountBalanceArgsDfx)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{icpledger.Tokens{ + *new(uint64), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.AccountBalanceArgsDfx{ + *new(string), + } + if _, err := a.AccountBalanceDfx(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_AccountIdentifier tests the "account_identifier" method on the "icpledger" canister. +func Test_AccountIdentifier(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "account_identifier", + Arguments: []any{new(icpledger.Account)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new([]byte)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.Account{ + *new(principal.Principal), + *new(*icpledger.SubAccount), + } + if _, err := a.AccountIdentifier(a0); err != nil { + t.Fatal(err) + } + +} + // Test_Archives tests the "archives" method on the "icpledger" canister. func Test_Archives(t *testing.T) { a, err := newAgent([]mock.Method{ @@ -89,6 +140,359 @@ func Test_Decimals(t *testing.T) { } +// Test_Icrc1BalanceOf tests the "icrc1_balance_of" method on the "icpledger" canister. +func Test_Icrc1BalanceOf(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_balance_of", + Arguments: []any{new(icpledger.Account)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{idl.NewNat(uint(0))}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.Account{ + *new(principal.Principal), + *new(*icpledger.SubAccount), + } + if _, err := a.Icrc1BalanceOf(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1Decimals tests the "icrc1_decimals" method on the "icpledger" canister. +func Test_Icrc1Decimals(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_decimals", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(uint8)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.Icrc1Decimals(); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1Fee tests the "icrc1_fee" method on the "icpledger" canister. +func Test_Icrc1Fee(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_fee", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{idl.NewNat(uint(0))}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.Icrc1Fee(); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1Metadata tests the "icrc1_metadata" method on the "icpledger" canister. +func Test_Icrc1Metadata(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_metadata", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{[]struct { + Field0 string `ic:"0" json:"0"` + Field1 icpledger.Value `ic:"1" json:"1"` + }{ + + { + *new(string), + icpledger.Value{ + Nat: idl.Ptr(idl.NewNat(uint(0))), + }, + }}}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.Icrc1Metadata(); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1MintingAccount tests the "icrc1_minting_account" method on the "icpledger" canister. +func Test_Icrc1MintingAccount(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_minting_account", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(*icpledger.Account)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.Icrc1MintingAccount(); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1Name tests the "icrc1_name" method on the "icpledger" canister. +func Test_Icrc1Name(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_name", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(string)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.Icrc1Name(); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1SupportedStandards tests the "icrc1_supported_standards" method on the "icpledger" canister. +func Test_Icrc1SupportedStandards(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_supported_standards", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{[]struct { + Name string `ic:"name" json:"name"` + Url string `ic:"url" json:"url"` + }{ + + { + *new(string), + *new(string), + }}}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.Icrc1SupportedStandards(); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1Symbol tests the "icrc1_symbol" method on the "icpledger" canister. +func Test_Icrc1Symbol(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_symbol", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(string)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.Icrc1Symbol(); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1TotalSupply tests the "icrc1_total_supply" method on the "icpledger" canister. +func Test_Icrc1TotalSupply(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_total_supply", + Arguments: []any{}, + Handler: func(request mock.Request) ([]any, error) { + return []any{idl.NewNat(uint(0))}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + if _, err := a.Icrc1TotalSupply(); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc1Transfer tests the "icrc1_transfer" method on the "icpledger" canister. +func Test_Icrc1Transfer(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc1_transfer", + Arguments: []any{new(icpledger.TransferArg)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{icpledger.Icrc1TransferResult{ + Ok: idl.Ptr(idl.NewNat(uint(0))), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.TransferArg{ + *new(*icpledger.SubAccount), + icpledger.Account{ + *new(principal.Principal), + *new(*icpledger.SubAccount), + }, + idl.NewNat(uint(0)), + *new(*icpledger.Icrc1Tokens), + *new(*[]byte), + *new(*icpledger.Icrc1Timestamp), + } + if _, err := a.Icrc1Transfer(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc2Allowance tests the "icrc2_allowance" method on the "icpledger" canister. +func Test_Icrc2Allowance(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc2_allowance", + Arguments: []any{new(icpledger.AllowanceArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{icpledger.Allowance{ + idl.NewNat(uint(0)), + *new(*icpledger.Icrc1Timestamp), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.AllowanceArgs{ + icpledger.Account{ + *new(principal.Principal), + *new(*icpledger.SubAccount), + }, + icpledger.Account{ + *new(principal.Principal), + *new(*icpledger.SubAccount), + }, + } + if _, err := a.Icrc2Allowance(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc2Approve tests the "icrc2_approve" method on the "icpledger" canister. +func Test_Icrc2Approve(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc2_approve", + Arguments: []any{new(icpledger.ApproveArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{icpledger.ApproveResult{ + Ok: idl.Ptr(idl.NewNat(uint(0))), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.ApproveArgs{ + *new(*icpledger.SubAccount), + icpledger.Account{ + *new(principal.Principal), + *new(*icpledger.SubAccount), + }, + idl.NewNat(uint(0)), + *new(*icpledger.Icrc1Tokens), + *new(*icpledger.Icrc1Timestamp), + *new(*icpledger.Icrc1Tokens), + *new(*[]byte), + *new(*icpledger.Icrc1Timestamp), + } + if _, err := a.Icrc2Approve(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_Icrc2TransferFrom tests the "icrc2_transfer_from" method on the "icpledger" canister. +func Test_Icrc2TransferFrom(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "icrc2_transfer_from", + Arguments: []any{new(icpledger.TransferFromArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{icpledger.TransferFromResult{ + Ok: idl.Ptr(idl.NewNat(uint(0))), + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.TransferFromArgs{ + *new(*icpledger.SubAccount), + icpledger.Account{ + *new(principal.Principal), + *new(*icpledger.SubAccount), + }, + icpledger.Account{ + *new(principal.Principal), + *new(*icpledger.SubAccount), + }, + idl.NewNat(uint(0)), + *new(*icpledger.Icrc1Tokens), + *new(*[]byte), + *new(*icpledger.Icrc1Timestamp), + } + if _, err := a.Icrc2TransferFrom(a0); err != nil { + t.Fatal(err) + } + +} + // Test_Name tests the "name" method on the "icpledger" canister. func Test_Name(t *testing.T) { a, err := newAgent([]mock.Method{ @@ -139,18 +543,12 @@ func Test_QueryBlocks(t *testing.T) { }, }}, *new(uint64), - []struct { - Start icpledger.BlockIndex `ic:"start" json:"start"` - Length uint64 `ic:"length" json:"length"` - Callback icpledger.QueryArchiveFn `ic:"callback" json:"callback"` - }{ - - { - *new(uint64), - *new(uint64), - *new(struct { /* NOT SUPPORTED */ - }), - }}, + []icpledger.ArchivedBlocksRange{{ + *new(uint64), + *new(uint64), + *new(struct { /* NOT SUPPORTED */ + }), + }}, }}, nil }, }, @@ -169,6 +567,75 @@ func Test_QueryBlocks(t *testing.T) { } +// Test_QueryEncodedBlocks tests the "query_encoded_blocks" method on the "icpledger" canister. +func Test_QueryEncodedBlocks(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "query_encoded_blocks", + Arguments: []any{new(icpledger.GetBlocksArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{icpledger.QueryEncodedBlocksResponse{ + *new(*[]byte), + [][]byte{*new([]byte)}, + *new(uint64), + *new(uint64), + []icpledger.ArchivedEncodedBlocksRange{{ + *new(struct { /* NOT SUPPORTED */ + }), + *new(uint64), + *new(uint64), + }}, + }}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.GetBlocksArgs{ + *new(uint64), + *new(uint64), + } + if _, err := a.QueryEncodedBlocks(a0); err != nil { + t.Fatal(err) + } + +} + +// Test_SendDfx tests the "send_dfx" method on the "icpledger" canister. +func Test_SendDfx(t *testing.T) { + a, err := newAgent([]mock.Method{ + { + Name: "send_dfx", + Arguments: []any{new(icpledger.SendArgs)}, + Handler: func(request mock.Request) ([]any, error) { + return []any{*new(uint64)}, nil + }, + }, + }) + if err != nil { + t.Fatal(err) + } + + var a0 = icpledger.SendArgs{ + *new(uint64), + icpledger.Tokens{ + *new(uint64), + }, + icpledger.Tokens{ + *new(uint64), + }, + *new(*icpledger.SubAccount), + *new(string), + *new(*icpledger.TimeStamp), + } + if _, err := a.SendDfx(a0); err != nil { + t.Fatal(err) + } + +} + // Test_Symbol tests the "symbol" method on the "icpledger" canister. func Test_Symbol(t *testing.T) { a, err := newAgent([]mock.Method{ diff --git a/ic/icpledger/types.mo b/ic/icpledger/types.mo index 67e153e..11ea210 100755 --- a/ic/icpledger/types.mo +++ b/ic/icpledger/types.mo @@ -14,13 +14,41 @@ module T { public type TransferFeeArg = { }; public type TransferFee = { transfer_fee : T.Tokens }; public type GetBlocksArgs = { start : T.BlockIndex; length : Nat64 }; - public type Operation = { #Mint : { to : T.AccountIdentifier; amount : T.Tokens }; #Burn : { from : T.AccountIdentifier; amount : T.Tokens }; #Transfer : { from : T.AccountIdentifier; to : T.AccountIdentifier; amount : T.Tokens; fee : T.Tokens }; #Approve : { from : T.AccountIdentifier; spender : T.AccountIdentifier; allowance_e8s : Int; fee : T.Tokens; expires_at : ?T.TimeStamp }; #TransferFrom : { from : T.AccountIdentifier; to : T.AccountIdentifier; spender : T.AccountIdentifier; amount : T.Tokens; fee : T.Tokens } }; + public type Operation = { #Mint : { to : T.AccountIdentifier; amount : T.Tokens }; #Burn : { from : T.AccountIdentifier; spender : ?T.AccountIdentifier; amount : T.Tokens }; #Transfer : { from : T.AccountIdentifier; to : T.AccountIdentifier; amount : T.Tokens; fee : T.Tokens; spender : ?[Nat8] }; #Approve : { from : T.AccountIdentifier; spender : T.AccountIdentifier; allowance_e8s : Int; allowance : T.Tokens; fee : T.Tokens; expires_at : ?T.TimeStamp; expected_allowance : ?T.Tokens } }; public type Block = { parent_hash : ?Blob; transaction : T.Transaction; timestamp : T.TimeStamp }; public type BlockRange = { blocks : [T.Block] }; public type QueryArchiveError = { #BadFirstBlockIndex : { requested_index : T.BlockIndex; first_valid_index : T.BlockIndex }; #Other : { error_code : Nat64; error_message : Text } }; public type QueryArchiveResult = { #Ok : T.BlockRange; #Err : T.QueryArchiveError }; public type QueryArchiveFn = { /* func */ }; - public type QueryBlocksResponse = { chain_length : Nat64; certificate : ?Blob; blocks : [T.Block]; first_block_index : T.BlockIndex; archived_blocks : [{ start : T.BlockIndex; length : Nat64; callback : T.QueryArchiveFn }] }; + public type QueryBlocksResponse = { chain_length : Nat64; certificate : ?Blob; blocks : [T.Block]; first_block_index : T.BlockIndex; archived_blocks : [T.ArchivedBlocksRange] }; + public type ArchivedBlocksRange = { start : T.BlockIndex; length : Nat64; callback : T.QueryArchiveFn }; + public type ArchivedEncodedBlocksRange = { callback : { /* func */ }; start : Nat64; length : Nat64 }; + public type QueryEncodedBlocksResponse = { certificate : ?Blob; blocks : [Blob]; chain_length : Nat64; first_block_index : Nat64; archived_blocks : [T.ArchivedEncodedBlocksRange] }; public type Archive = { canister_id : Principal }; public type Archives = { archives : [T.Archive] }; + public type Duration = { secs : Nat64; nanos : Nat32 }; + public type ArchiveOptions = { trigger_threshold : Nat64; num_blocks_to_archive : Nat64; node_max_memory_size_bytes : ?Nat64; max_message_size_bytes : ?Nat64; controller_id : Principal; more_controller_ids : ?[Principal]; cycles_for_archive_creation : ?Nat64; max_transactions_per_response : ?Nat64 }; + public type TextAccountIdentifier = Text; + public type SendArgs = { memo : T.Memo; amount : T.Tokens; fee : T.Tokens; from_subaccount : ?T.SubAccount; to : T.TextAccountIdentifier; created_at_time : ?T.TimeStamp }; + public type AccountBalanceArgsDfx = { account : T.TextAccountIdentifier }; + public type FeatureFlags = { icrc2 : Bool }; + public type InitArgs = { minting_account : T.TextAccountIdentifier; icrc1_minting_account : ?T.Account; initial_values : [(T.TextAccountIdentifier, T.Tokens)]; max_message_size_bytes : ?Nat64; transaction_window : ?T.Duration; archive_options : ?T.ArchiveOptions; send_whitelist : [Principal]; transfer_fee : ?T.Tokens; token_symbol : ?Text; token_name : ?Text; feature_flags : ?T.FeatureFlags; maximum_number_of_accounts : ?Nat64; accounts_overflow_trim_quantity : ?Nat64 }; + public type Icrc1BlockIndex = Nat; + public type Icrc1Timestamp = Nat64; + public type Icrc1Tokens = Nat; + public type Account = { owner : Principal; subaccount : ?T.SubAccount }; + public type TransferArg = { from_subaccount : ?T.SubAccount; to : T.Account; amount : T.Icrc1Tokens; fee : ?T.Icrc1Tokens; memo : ?Blob; created_at_time : ?T.Icrc1Timestamp }; + public type Icrc1TransferError = { #BadFee : { expected_fee : T.Icrc1Tokens }; #BadBurn : { min_burn_amount : T.Icrc1Tokens }; #InsufficientFunds : { balance : T.Icrc1Tokens }; #TooOld; #CreatedInFuture : { ledger_time : Nat64 }; #TemporarilyUnavailable; #Duplicate : { duplicate_of : T.Icrc1BlockIndex }; #GenericError : { error_code : Nat; message : Text } }; + public type Icrc1TransferResult = { #Ok : T.Icrc1BlockIndex; #Err : T.Icrc1TransferError }; + public type Value = { #Nat : Nat; #Int : Int; #Text : Text; #Blob : Blob }; + public type UpgradeArgs = { maximum_number_of_accounts : ?Nat64; icrc1_minting_account : ?T.Account; feature_flags : ?T.FeatureFlags }; + public type LedgerCanisterPayload = { #Init : T.InitArgs; #Upgrade : ?T.UpgradeArgs }; + public type ApproveArgs = { from_subaccount : ?T.SubAccount; spender : T.Account; amount : T.Icrc1Tokens; expected_allowance : ?T.Icrc1Tokens; expires_at : ?T.Icrc1Timestamp; fee : ?T.Icrc1Tokens; memo : ?Blob; created_at_time : ?T.Icrc1Timestamp }; + public type ApproveError = { #BadFee : { expected_fee : T.Icrc1Tokens }; #InsufficientFunds : { balance : T.Icrc1Tokens }; #AllowanceChanged : { current_allowance : T.Icrc1Tokens }; #Expired : { ledger_time : Nat64 }; #TooOld; #CreatedInFuture : { ledger_time : Nat64 }; #Duplicate : { duplicate_of : T.Icrc1BlockIndex }; #TemporarilyUnavailable; #GenericError : { error_code : Nat; message : Text } }; + public type ApproveResult = { #Ok : T.Icrc1BlockIndex; #Err : T.ApproveError }; + public type AllowanceArgs = { account : T.Account; spender : T.Account }; + public type Allowance = { allowance : T.Icrc1Tokens; expires_at : ?T.Icrc1Timestamp }; + public type TransferFromArgs = { spender_subaccount : ?T.SubAccount; from : T.Account; to : T.Account; amount : T.Icrc1Tokens; fee : ?T.Icrc1Tokens; memo : ?Blob; created_at_time : ?T.Icrc1Timestamp }; + public type TransferFromResult = { #Ok : T.Icrc1BlockIndex; #Err : T.TransferFromError }; + public type TransferFromError = { #BadFee : { expected_fee : T.Icrc1Tokens }; #BadBurn : { min_burn_amount : T.Icrc1Tokens }; #InsufficientFunds : { balance : T.Icrc1Tokens }; #InsufficientAllowance : { allowance : T.Icrc1Tokens }; #TooOld; #CreatedInFuture : { ledger_time : T.Icrc1Timestamp }; #Duplicate : { duplicate_of : T.Icrc1BlockIndex }; #TemporarilyUnavailable; #GenericError : { error_code : Nat; message : Text } }; }; diff --git a/ic/icrc1/actor.mo b/ic/icrc1/actor.mo index e0e58ad..2cff35d 100755 --- a/ic/icrc1/actor.mo +++ b/ic/icrc1/actor.mo @@ -3,7 +3,7 @@ import T "types"; import { principalOfBlob } = "mo:⛔"; -actor class icrc1() : async actor {} { +actor class _icrc1() : async actor {} { public query func icrc1_metadata() : async ([(Text, T.Value)]) { ([ ( "8461085577816129895", #Int(5878529396228072694) ), ( "17086874607426100806", #Text("10709273831789307773") ), ( "16878655614376436083", #Int(6759167820548538355) ), ( "18292591075080601467", #Nat(17811010120847317546) ), ( "18177279855461275382", #Int(5653783580888133841) ), ( "7999443096767709278", #Int(18374081214496534973) ) ]) }; @@ -25,10 +25,10 @@ actor class icrc1() : async actor {} { public query func icrc1_minting_account() : async (?T.Account) { (?{ owner = principalOfBlob("xF273F5F14EF71A6741E91781D06B5D360F3EE11F56F6A4DD0F57BB94465E46E1"); subaccount = ?"xBE56FB9FA308657D273052CFFB9E73610FB5DA073D79779DC770CD9DF3FF0B39" }) }; - public query func icrc1_balance_of(arg0 : T.Account) : async (Nat) { + public query func icrc1_balance_of(_arg0 : T.Account) : async (Nat) { (15860260956177527794) }; - public shared func icrc1_transfer(arg0 : T.TransferArgs) : async ({ #Ok : Nat; #Err : T.TransferError }) { + public shared func icrc1_transfer(_arg0 : T.TransferArgs) : async ({ #Ok : Nat; #Err : T.TransferError }) { (#Ok(8461085577816129895)) }; public query func icrc1_supported_standards() : async ([{ name : Text; url : Text }]) { diff --git a/ic/testdata/did/assetstorage.did b/ic/testdata/did/assetstorage.did index e6c0d8a..51bb1a2 100644 --- a/ic/testdata/did/assetstorage.did +++ b/ic/testdata/did/assetstorage.did @@ -1,5 +1,3 @@ -// SOURCE: https://github.com/dfinity/sdk/blob/c1ecdaad0257e79cedbc19c485b86021831fa4b7/src/distributed/assetstorage.did - type BatchId = nat; type ChunkId = nat; type Key = text; @@ -111,6 +109,18 @@ type SetAssetPropertiesArguments = record { is_aliased: opt opt bool; }; +type ConfigurationResponse = record { + max_batches: opt nat64; + max_chunks: opt nat64; + max_bytes: opt nat64; +}; + +type ConfigureArguments = record { + max_batches: opt opt nat64; + max_chunks: opt opt nat64; + max_bytes: opt opt nat64; +}; + type Permission = variant { Commit; ManagePermissions; @@ -129,7 +139,25 @@ type ListPermitted = record { permission: Permission }; type ValidationResult = variant { Ok : text; Err : text }; -service: { +type AssetCanisterArgs = variant { + Init: InitArgs; + Upgrade: UpgradeArgs; +}; + +type InitArgs = record {}; + +type UpgradeArgs = record { + set_permissions: opt SetPermissions; +}; + +/// Sets the list of principals granted each permission. +type SetPermissions = record { + prepare: vec principal; + commit: vec principal; + manage_permissions: vec principal; +}; + +service: (asset_canister_args: opt AssetCanisterArgs) -> { api_version: () -> (nat16) query; get: (record { @@ -210,10 +238,10 @@ service: { authorize: (principal) -> (); deauthorize: (principal) -> (); - list_authorized: () -> (vec principal) query; + list_authorized: () -> (vec principal); grant_permission: (GrantPermission) -> (); revoke_permission: (RevokePermission) -> (); - list_permitted: (ListPermitted) -> (vec principal) query; + list_permitted: (ListPermitted) -> (vec principal); take_ownership: () -> (); get_asset_properties : (key: Key) -> (record { @@ -223,8 +251,12 @@ service: { is_aliased: opt bool; } ) query; set_asset_properties: (SetAssetPropertiesArguments) -> (); + get_configuration: () -> (ConfigurationResponse); + configure: (ConfigureArguments) -> (); + validate_grant_permission: (GrantPermission) -> (ValidationResult); validate_revoke_permission: (RevokePermission) -> (ValidationResult); validate_take_ownership: () -> (ValidationResult); validate_commit_proposed_batch: (CommitProposedBatchArguments) -> (ValidationResult); + validate_configure: (ConfigureArguments) -> (ValidationResult); } diff --git a/ic/testdata/did/cmc.did b/ic/testdata/did/cmc.did index e2b4a3c..a7885ea 100644 --- a/ic/testdata/did/cmc.did +++ b/ic/testdata/did/cmc.did @@ -1,7 +1,21 @@ -// SOURCE: https://github.com/dfinity/ic/blob/d35535c96184be039aaa31f68b48bbe45909494e/rs/nns/cmc/cmc.did - type Cycles = nat; type BlockIndex = nat64; +type log_visibility = variant { + controllers; + public; +}; +type CanisterSettings = record { + controller : opt principal; + controllers : opt vec principal; + compute_allocation : opt nat; + memory_allocation : opt nat; + freezing_threshold : opt nat; + reserved_cycles_limit: opt nat; + log_visibility : opt log_visibility; + wasm_memory_limit: opt nat; +}; +type Subaccount = opt blob; +type Memo = opt blob; // The argument of the [notify_top_up] method. type NotifyTopUpArg = record { @@ -12,6 +26,35 @@ type NotifyTopUpArg = record { canister_id : principal; }; + +type SubnetSelection = variant { + /// Choose a specific subnet + Subnet : record { + subnet: principal; + }; + /// Choose a random subnet that fulfills the specified properties + Filter : SubnetFilter; +}; + +type SubnetFilter = record { + subnet_type: opt text; +}; + +// The argument of the [create_canister] method. +type CreateCanisterArg = record { + // Optional canister settings that, if set, are applied to the newly created canister. + // If not specified, the caller is the controller of the canister and the other settings are set to default values. + settings : opt CanisterSettings; + + // An optional subnet type that, if set, determines what type of subnet + // the new canister will be created on. + // Deprecated. Use subnet_selection instead. + subnet_type: opt text; + + // Optional instructions to select on which subnet the new canister will be created on. + subnet_selection: opt SubnetSelection; +}; + // The argument of the [notify_create_canister] method. type NotifyCreateCanisterArg = record { // Index of the block on the ICP ledger that contains the payment. @@ -22,7 +65,35 @@ type NotifyCreateCanisterArg = record { // An optional subnet type that, if set, determines what type of subnet // the new canister will be created on. + // Deprecated. Use subnet_selection instead. subnet_type: opt text; + + // Optional instructions to select on which subnet the new canister will be created on. + // vec may contain no more than one element. + subnet_selection: opt SubnetSelection; + + // Optional canister settings that, if set, are applied to the newly created canister. + // If not specified, the caller is the controller of the canister and the other settings are set to default values. + settings : opt CanisterSettings; +}; + +// Canister creation failed and the cycles attached to the call were returned to the calling canister. +// A small fee may be charged. +type CreateCanisterError = variant { + Refunded : record { + // The amount of cycles returned to the calling canister + refund_amount: nat; + + // The reason why creating a canister failed. + create_error: text; + }; + RefundFailed : record { + // The reason why creating a canister failed. + create_error: text; + + // The reason why refunding cycles failed. + refund_error: text; + }; }; type NotifyError = variant { @@ -59,6 +130,12 @@ type NotifyTopUpResult = variant { Err : NotifyError; }; +type CreateCanisterResult = variant { + // The principal of the newly created canister. + Ok : principal; + Err : CreateCanisterError; +}; + type NotifyCreateCanisterResult = variant { // The principal of the newly created canister. Ok : principal; @@ -81,7 +158,7 @@ type IcpXdrConversionRateResponse = record { data : IcpXdrConversionRate; // CBOR-serialized hash tree as specified in - // https://smartcontracts.org/docs/interface-spec/index.html#certification-encoding. + // https://internetcomputer.org/docs/interface-spec/index.html#certification-encoding // The hash tree is used for certification and hash the following structure: // ``` // * @@ -93,7 +170,7 @@ type IcpXdrConversionRateResponse = record { hash_tree : blob; // System certificate as specified in - // https://smartcontracts.org/docs/interface-spec/index.html#certification-encoding + // https://internetcomputer.org/docs/interface-spec/index.html#certification-encoding certificate : blob; }; @@ -101,10 +178,12 @@ type SubnetTypesToSubnetsResponse = record { data: vec record { text; vec principal }; }; -type AccountIdentifier = record { - bytes: blob; +type PrincipalsAuthorizedToCreateCanistersToSubnetsResponse = record { + data: vec record { principal; vec principal }; }; +type AccountIdentifier = text; + type ExchangeRateCanister = variant { /// Enables the exchange rate canister with the given canister ID. Set: principal; @@ -118,19 +197,52 @@ type CyclesCanisterInitPayload = record { minting_account_id: opt AccountIdentifier; last_purged_notification: opt nat64; exchange_rate_canister: opt ExchangeRateCanister; + cycles_ledger_canister_id: opt principal; +}; + +type NotifyMintCyclesArg = record { + block_index: BlockIndex; + to_subaccount: Subaccount; + deposit_memo: Memo; +}; + +type NotifyMintCyclesResult = variant { + Ok: NotifyMintCyclesSuccess; + Err: NotifyError; +}; + +type NotifyMintCyclesSuccess = record { + // Cycles ledger block index of deposit + block_index: nat; + // Amount of cycles that were minted and deposited to the cycles ledger + minted: nat; + // New balance of the cycles ledger account + balance: nat; }; service : (opt CyclesCanisterInitPayload) -> { - // Propmts the cycles minting canister to process a payment by converting ICP + // Prompts the cycles minting canister to process a payment by converting ICP // into cycles and sending the cycles the specified canister. notify_top_up : (NotifyTopUpArg) -> (NotifyTopUpResult); + // Creates a canister using the cycles attached to the function call. + create_canister : (CreateCanisterArg) -> (CreateCanisterResult); + // Prompts the cycles minting canister to process a payment for canister creation. notify_create_canister : (NotifyCreateCanisterArg) -> (NotifyCreateCanisterResult); + // Mints cycles and deposits them to the cycles ledger + notify_mint_cycles : (NotifyMintCyclesArg) -> (NotifyMintCyclesResult); + // Returns the ICP/XDR conversion rate. get_icp_xdr_conversion_rate : () -> (IcpXdrConversionRateResponse) query; // Returns the current mapping of subnet types to subnets. get_subnet_types_to_subnets : () -> (SubnetTypesToSubnetsResponse) query; + + // Returns the mapping from principals to subnets in which they are authorized + // to create canisters. + get_principals_authorized_to_create_canisters_to_subnets : () -> (PrincipalsAuthorizedToCreateCanistersToSubnetsResponse) query; + + get_build_metadata : () -> (text) query; } diff --git a/ic/testdata/did/ic.did b/ic/testdata/did/ic.did new file mode 100644 index 0000000..a34f331 --- /dev/null +++ b/ic/testdata/did/ic.did @@ -0,0 +1,361 @@ +type canister_id = principal; +type wasm_module = blob; + +type canister_settings = record { + controllers : opt vec principal; + compute_allocation : opt nat; + memory_allocation : opt nat; + freezing_threshold : opt nat; + reserved_cycles_limit : opt nat; +}; + +type definite_canister_settings = record { + controllers : vec principal; + compute_allocation : nat; + memory_allocation : nat; + freezing_threshold : nat; + reserved_cycles_limit : nat; +}; + +type change_origin = variant { + from_user : record { + user_id : principal; + }; + from_canister : record { + canister_id : principal; + canister_version : opt nat64; + }; +}; + +type change_details = variant { + creation : record { + controllers : vec principal; + }; + code_uninstall; + code_deployment : record { + mode : variant { install; reinstall; upgrade }; + module_hash : blob; + }; + controllers_change : record { + controllers : vec principal; + }; +}; + +type change = record { + timestamp_nanos : nat64; + canister_version : nat64; + origin : change_origin; + details : change_details; +}; + +type chunk_hash = record { + hash : blob; +}; + +type http_header = record { + name : text; + value : text; +}; + +type http_request_result = record { + status : nat; + headers : vec http_header; + body : blob; +}; + +type ecdsa_curve = variant { + secp256k1; +}; + +type satoshi = nat64; + +type bitcoin_network = variant { + mainnet; + testnet; +}; + +type bitcoin_address = text; + +type block_hash = blob; + +type outpoint = record { + txid : blob; + vout : nat32; +}; + +type utxo = record { + outpoint : outpoint; + value : satoshi; + height : nat32; +}; + +type bitcoin_get_utxos_args = record { + address : bitcoin_address; + network : bitcoin_network; + filter : opt variant { + min_confirmations : nat32; + page : blob; + }; +}; + +type bitcoin_get_utxos_query_args = record { + address : bitcoin_address; + network : bitcoin_network; + filter : opt variant { + min_confirmations : nat32; + page : blob; + }; +}; + +type bitcoin_get_current_fee_percentiles_args = record { + network : bitcoin_network; +}; + +type bitcoin_get_utxos_result = record { + utxos : vec utxo; + tip_block_hash : block_hash; + tip_height : nat32; + next_page : opt blob; +}; + +type bitcoin_get_utxos_query_result = record { + utxos : vec utxo; + tip_block_hash : block_hash; + tip_height : nat32; + next_page : opt blob; +}; + +type bitcoin_get_balance_args = record { + address : bitcoin_address; + network : bitcoin_network; + min_confirmations : opt nat32; +}; + +type bitcoin_get_balance_query_args = record { + address : bitcoin_address; + network : bitcoin_network; + min_confirmations : opt nat32; +}; + +type bitcoin_send_transaction_args = record { + transaction : blob; + network : bitcoin_network; +}; + +type millisatoshi_per_byte = nat64; + +type node_metrics = record { + node_id : principal; + num_blocks_total : nat64; + num_block_failures_total : nat64; +}; + +type create_canister_args = record { + settings : opt canister_settings; + sender_canister_version : opt nat64; +}; + +type create_canister_result = record { + canister_id : canister_id; +}; + +type update_settings_args = record { + canister_id : principal; + settings : canister_settings; + sender_canister_version : opt nat64; +}; + +type upload_chunk_args = record { + canister_id : principal; + chunk : blob; +}; + +type clear_chunk_store_args = record { + canister_id : canister_id; +}; + +type stored_chunks_args = record { + canister_id : canister_id; +}; + +type canister_install_mode = variant { + install; + reinstall; + upgrade : opt record { + skip_pre_upgrade : opt bool; + }; +}; + +type install_code_args = record { + mode : canister_install_mode; + canister_id : canister_id; + wasm_module : wasm_module; + arg : blob; + sender_canister_version : opt nat64; +}; + +type install_chunked_code_args = record { + mode : canister_install_mode; + target_canister : canister_id; + store_canister : opt canister_id; + chunk_hashes_list : vec chunk_hash; + wasm_module_hash : blob; + arg : blob; + sender_canister_version : opt nat64; +}; + +type uninstall_code_args = record { + canister_id : canister_id; + sender_canister_version : opt nat64; +}; + +type start_canister_args = record { + canister_id : canister_id; +}; + +type stop_canister_args = record { + canister_id : canister_id; +}; + +type canister_status_args = record { + canister_id : canister_id; +}; + +type canister_status_result = record { + status : variant { running; stopping; stopped }; + settings : definite_canister_settings; + module_hash : opt blob; + memory_size : nat; + cycles : nat; + reserved_cycles : nat; + idle_cycles_burned_per_day : nat; +}; + +type canister_info_args = record { + canister_id : canister_id; + num_requested_changes : opt nat64; +}; + +type canister_info_result = record { + total_num_changes : nat64; + recent_changes : vec change; + module_hash : opt blob; + controllers : vec principal; +}; + +type delete_canister_args = record { + canister_id : canister_id; +}; + +type deposit_cycles_args = record { + canister_id : canister_id; +}; + +type http_request_args = record { + url : text; + max_response_bytes : opt nat64; + method : variant { get; head; post }; + headers : vec http_header; + body : opt blob; + transform : opt record { + function : func(record { response : http_request_result; context : blob }) -> (http_request_result) query; + context : blob; + }; +}; + +type ecdsa_public_key_args = record { + canister_id : opt canister_id; + derivation_path : vec blob; + key_id : record { curve : ecdsa_curve; name : text }; +}; + +type ecdsa_public_key_result = record { + public_key : blob; + chain_code : blob; +}; + +type sign_with_ecdsa_args = record { + message_hash : blob; + derivation_path : vec blob; + key_id : record { curve : ecdsa_curve; name : text }; +}; + +type sign_with_ecdsa_result = record { + signature : blob; +}; + +type node_metrics_history_args = record { + subnet_id : principal; + start_at_timestamp_nanos : nat64; +}; + +type node_metrics_history_result = vec record { + timestamp_nanos : nat64; + node_metrics : vec node_metrics; +}; + +type provisional_create_canister_with_cycles_args = record { + amount : opt nat; + settings : opt canister_settings; + specified_id : opt canister_id; + sender_canister_version : opt nat64; +}; + +type provisional_create_canister_with_cycles_result = record { + canister_id : canister_id; +}; + +type provisional_top_up_canister_args = record { + canister_id : canister_id; + amount : nat; +}; + +type raw_rand_result = blob; + +type stored_chunks_result = vec chunk_hash; + +type upload_chunk_result = chunk_hash; + +type bitcoin_get_balance_result = satoshi; + +type bitcoin_get_balance_query_result = satoshi; + +type bitcoin_get_current_fee_percentiles_result = vec millisatoshi_per_byte; + +service ic : { + create_canister : (create_canister_args) -> (create_canister_result); + update_settings : (update_settings_args) -> (); + upload_chunk : (upload_chunk_args) -> (upload_chunk_result); + clear_chunk_store : (clear_chunk_store_args) -> (); + stored_chunks : (stored_chunks_args) -> (stored_chunks_result); + install_code : (install_code_args) -> (); + install_chunked_code : (install_chunked_code_args) -> (); + uninstall_code : (uninstall_code_args) -> (); + start_canister : (start_canister_args) -> (); + stop_canister : (stop_canister_args) -> (); + canister_status : (canister_status_args) -> (canister_status_result); + canister_info : (canister_info_args) -> (canister_info_result); + delete_canister : (delete_canister_args) -> (); + deposit_cycles : (deposit_cycles_args) -> (); + raw_rand : () -> (raw_rand_result); + http_request : (http_request_args) -> (http_request_result); + + // Threshold ECDSA signature + ecdsa_public_key : (ecdsa_public_key_args) -> (ecdsa_public_key_result); + sign_with_ecdsa : (sign_with_ecdsa_args) -> (sign_with_ecdsa_result); + + // bitcoin interface + bitcoin_get_balance : (bitcoin_get_balance_args) -> (bitcoin_get_balance_result); + bitcoin_get_balance_query : (bitcoin_get_balance_query_args) -> (bitcoin_get_balance_query_result) query; + bitcoin_get_utxos : (bitcoin_get_utxos_args) -> (bitcoin_get_utxos_result); + bitcoin_get_utxos_query : (bitcoin_get_utxos_query_args) -> (bitcoin_get_utxos_query_result) query; + bitcoin_send_transaction : (bitcoin_send_transaction_args) -> (); + bitcoin_get_current_fee_percentiles : (bitcoin_get_current_fee_percentiles_args) -> (bitcoin_get_current_fee_percentiles_result); + + // metrics interface + node_metrics_history : (node_metrics_history_args) -> (node_metrics_history_result); + + // provisional interfaces for the pre-ledger world + provisional_create_canister_with_cycles : (provisional_create_canister_with_cycles_args) -> (provisional_create_canister_with_cycles_result); + provisional_top_up_canister : (provisional_top_up_canister_args) -> (); +}; diff --git a/ic/testdata/did/icparchive.did b/ic/testdata/did/icparchive.did index bb391d0..66fd5a4 100644 --- a/ic/testdata/did/icparchive.did +++ b/ic/testdata/did/icparchive.did @@ -1,5 +1,3 @@ -// SOURCE: https://github.com/dfinity/ic/blob/a1f503d20b7846375c74ce5f7d0f8f6620ab7511/rs/rosetta-api/icp_ledger/ledger_archive.did - type BlockIndex = nat64; type Memo = nat64; type AccountIdentifier = blob; @@ -13,6 +11,7 @@ type Operation = variant { }; Burn : record { from : AccountIdentifier; + spender : opt AccountIdentifier; amount : Tokens; }; Transfer : record { @@ -20,20 +19,17 @@ type Operation = variant { to : AccountIdentifier; amount : Tokens; fee : Tokens; + spender : opt vec nat8; }; Approve : record { from : AccountIdentifier; spender : AccountIdentifier; + // This field is deprecated and should not be used. allowance_e8s : int; + allowance: Tokens; fee : Tokens; expires_at : opt Timestamp; - }; - TransferFrom : record { - from : AccountIdentifier; - to : AccountIdentifier; - spender : AccountIdentifier; - amount : Tokens; - fee : Tokens; + expected_allowance : opt Tokens; }; }; @@ -81,6 +77,9 @@ type GetBlocksResult = variant { Err : GetBlocksError; }; +type GetEncodedBlocksResult = variant { Ok : vec blob; Err : GetBlocksError }; + service : { get_blocks : (GetBlocksArgs) -> (GetBlocksResult) query; -} + get_encoded_blocks : (GetBlocksArgs) -> (GetEncodedBlocksResult) query; +} \ No newline at end of file diff --git a/ic/testdata/did/icpledger.did b/ic/testdata/did/icpledger.did index e8e8177..124d40a 100644 --- a/ic/testdata/did/icpledger.did +++ b/ic/testdata/did/icpledger.did @@ -1,5 +1,3 @@ -// SOURCE: https://github.com/dfinity/ic/blob/d35535c96184be039aaa31f68b48bbe45909494e/rs/rosetta-api/icp_ledger/ledger.did - // This is the official Ledger interface that is guaranteed to be backward compatible. // Amount of tokens, measured in 10^-8 of a token. @@ -106,6 +104,7 @@ type Operation = variant { }; Burn : record { from : AccountIdentifier; + spender : opt AccountIdentifier; amount : Tokens; }; Transfer : record { @@ -113,24 +112,21 @@ type Operation = variant { to : AccountIdentifier; amount : Tokens; fee : Tokens; + spender : opt vec nat8; }; Approve : record { from : AccountIdentifier; spender : AccountIdentifier; + // This field is deprecated and should not be used. allowance_e8s : int; + allowance: Tokens; fee : Tokens; expires_at : opt TimeStamp; - }; - TransferFrom : record { - from : AccountIdentifier; - to : AccountIdentifier; - spender : AccountIdentifier; - amount : Tokens; - fee : Tokens; + expected_allowance : opt Tokens; }; }; - + type Block = record { parent_hash : opt blob; @@ -188,7 +184,7 @@ type QueryArchiveFn = func (GetBlocksArgs) -> (QueryArchiveResult) query; // not have all the blocks that the caller requested: One or more "archive" canisters might // store some of the requested blocks. // -// Note: as of Q4 2021 when this interface is authored, the IC doesn't support making nested +// Note: as of Q4 2021 when this interface is authored, the IC doesn't support making nested // query calls within a query call. type QueryBlocksResponse = record { // The total number of blocks in the chain. @@ -217,18 +213,36 @@ type QueryBlocksResponse = record { // // For each entry `e` in [archived_blocks], `[e.from, e.from + len)` is a sub-range // of the originally requested block range. - archived_blocks : vec record { - // The index of the first archived block that can be fetched using the callback. - start : BlockIndex; + archived_blocks : vec ArchivedBlocksRange; +}; - // The number of blocks that can be fetch using the callback. - length : nat64; +type ArchivedBlocksRange = record { + // The index of the first archived block that can be fetched using the callback. + start : BlockIndex; - // The function that should be called to fetch the archived blocks. - // The range of the blocks accessible using this function is given by [from] - // and [len] fields above. - callback : QueryArchiveFn; - }; + // The number of blocks that can be fetch using the callback. + length : nat64; + + // The function that should be called to fetch the archived blocks. + // The range of the blocks accessible using this function is given by [from] + // and [len] fields above. + callback : QueryArchiveFn; +}; + +type ArchivedEncodedBlocksRange = record { + callback : func (GetBlocksArgs) -> ( + variant { Ok : vec blob; Err : QueryArchiveError }, + ) query; + start : nat64; + length : nat64; +}; + +type QueryEncodedBlocksResponse = record { + certificate : opt blob; + blocks : vec blob; + chain_length : nat64; + first_block_index : nat64; + archived_blocks : vec ArchivedEncodedBlocksRange; }; type Archive = record { @@ -239,30 +253,227 @@ type Archives = record { archives: vec Archive; }; -service : { - // Transfers tokens from a subaccount of the caller to the destination address. - // The source address is computed from the principal of the caller and the specified subaccount. - // When successful, returns the index of the block containing the transaction. - transfer : (TransferArgs) -> (TransferResult); +type Duration = record { + secs: nat64; + nanos: nat32; +}; + +type ArchiveOptions = record { + trigger_threshold : nat64; + num_blocks_to_archive : nat64; + node_max_memory_size_bytes : opt nat64; + max_message_size_bytes : opt nat64; + controller_id : principal; + more_controller_ids: opt vec principal; + cycles_for_archive_creation : opt nat64; + max_transactions_per_response : opt nat64; +}; + +// Account identifier encoded as a 64-byte ASCII hex string. +type TextAccountIdentifier = text; + +// Arguments for the `send_dfx` call. +type SendArgs = record { + memo: Memo; + amount: Tokens; + fee: Tokens; + from_subaccount: opt SubAccount; + to: TextAccountIdentifier; + created_at_time: opt TimeStamp; +}; + +type AccountBalanceArgsDfx = record { + account: TextAccountIdentifier; +}; + +type FeatureFlags = record { + icrc2 : bool; +}; + +type InitArgs = record { + minting_account: TextAccountIdentifier; + icrc1_minting_account: opt Account; + initial_values: vec record {TextAccountIdentifier; Tokens}; + max_message_size_bytes: opt nat64; + transaction_window: opt Duration; + archive_options: opt ArchiveOptions; + send_whitelist: vec principal; + transfer_fee: opt Tokens; + token_symbol: opt text; + token_name: opt text; + feature_flags : opt FeatureFlags; + maximum_number_of_accounts : opt nat64; + accounts_overflow_trim_quantity: opt nat64; +}; + +type Icrc1BlockIndex = nat; +// Number of nanoseconds since the UNIX epoch in UTC timezone. +type Icrc1Timestamp = nat64; +type Icrc1Tokens = nat; + +type Account = record { + owner : principal; + subaccount : opt SubAccount; +}; + +type TransferArg = record { + from_subaccount : opt SubAccount; + to : Account; + amount : Icrc1Tokens; + fee : opt Icrc1Tokens; + memo : opt blob; + created_at_time: opt Icrc1Timestamp; +}; - // Returns the amount of Tokens on the specified account. - account_balance : (AccountBalanceArgs) -> (Tokens) query; +type Icrc1TransferError = variant { + BadFee : record { expected_fee : Icrc1Tokens }; + BadBurn : record { min_burn_amount : Icrc1Tokens }; + InsufficientFunds : record { balance : Icrc1Tokens }; + TooOld; + CreatedInFuture : record { ledger_time : nat64 }; + TemporarilyUnavailable; + Duplicate : record { duplicate_of : Icrc1BlockIndex }; + GenericError : record { error_code : nat; message : text }; +}; - // Returns the current transfer_fee. - transfer_fee : (TransferFeeArg) -> (TransferFee) query; +type Icrc1TransferResult = variant { + Ok : Icrc1BlockIndex; + Err : Icrc1TransferError; +}; - // Queries blocks in the specified range. - query_blocks : (GetBlocksArgs) -> (QueryBlocksResponse) query; +// The value returned from the [icrc1_metadata] endpoint. +type Value = variant { + Nat : nat; + Int : int; + Text : text; + Blob : blob; +}; - // Returns token symbol. - symbol : () -> (record { symbol: text }) query; +type UpgradeArgs = record { + maximum_number_of_accounts : opt nat64; + icrc1_minting_account : opt Account; + feature_flags : opt FeatureFlags; +}; - // Returns token name. - name : () -> (record { name: text }) query; +type LedgerCanisterPayload = variant { + Init: InitArgs; + Upgrade: opt UpgradeArgs; +}; - // Returns token decimals. - decimals : () -> (record { decimals: nat32 }) query; +type ApproveArgs = record { + from_subaccount : opt SubAccount; + spender : Account; + amount : Icrc1Tokens; + expected_allowance : opt Icrc1Tokens; + expires_at : opt Icrc1Timestamp; + fee : opt Icrc1Tokens; + memo : opt blob; + created_at_time: opt Icrc1Timestamp; +}; + +type ApproveError = variant { + BadFee : record { expected_fee : Icrc1Tokens }; + InsufficientFunds : record { balance : Icrc1Tokens }; + AllowanceChanged : record { current_allowance : Icrc1Tokens }; + Expired : record { ledger_time : nat64 }; + TooOld; + CreatedInFuture : record { ledger_time : nat64 }; + Duplicate : record { duplicate_of : Icrc1BlockIndex }; + TemporarilyUnavailable; + GenericError : record { error_code : nat; message : text }; +}; + +type ApproveResult = variant { + Ok : Icrc1BlockIndex; + Err : ApproveError; +}; + +type AllowanceArgs = record { + account : Account; + spender : Account; +}; + +type Allowance = record { + allowance : Icrc1Tokens; + expires_at : opt Icrc1Timestamp; +}; + +type TransferFromArgs = record { + spender_subaccount : opt SubAccount; + from : Account; + to : Account; + amount : Icrc1Tokens; + fee : opt Icrc1Tokens; + memo : opt blob; + created_at_time: opt Icrc1Timestamp; +}; + +type TransferFromResult = variant { + Ok : Icrc1BlockIndex; + Err : TransferFromError; +}; + +type TransferFromError = variant { + BadFee : record { expected_fee : Icrc1Tokens }; + BadBurn : record { min_burn_amount : Icrc1Tokens }; + InsufficientFunds : record { balance : Icrc1Tokens }; + InsufficientAllowance : record { allowance : Icrc1Tokens }; + TooOld; + CreatedInFuture : record { ledger_time : Icrc1Timestamp }; + Duplicate : record { duplicate_of : Icrc1BlockIndex }; + TemporarilyUnavailable; + GenericError : record { error_code : nat; message : text }; +}; - // Returns the existing archive canisters information. - archives : () -> (Archives) query; +service: (LedgerCanisterPayload) -> { + // Transfers tokens from a subaccount of the caller to the destination address. + // The source address is computed from the principal of the caller and the specified subaccount. + // When successful, returns the index of the block containing the transaction. + transfer : (TransferArgs) -> (TransferResult); + + // Returns the amount of Tokens on the specified account. + account_balance : (AccountBalanceArgs) -> (Tokens) query; + + // Returns the account identifier for the given Principal and subaccount. + account_identifier : (Account) -> (AccountIdentifier) query; + + // Returns the current transfer_fee. + transfer_fee : (TransferFeeArg) -> (TransferFee) query; + + // Queries blocks in the specified range. + query_blocks : (GetBlocksArgs) -> (QueryBlocksResponse) query; + + // Queries encoded blocks in the specified range + query_encoded_blocks : (GetBlocksArgs) -> (QueryEncodedBlocksResponse) query; + + // Returns token symbol. + symbol : () -> (record { symbol: text }) query; + + // Returns token name. + name : () -> (record { name: text }) query; + + // Returns token decimals. + decimals : () -> (record { decimals: nat32 }) query; + + // Returns the existing archive canisters information. + archives : () -> (Archives) query; + + send_dfx : (SendArgs) -> (BlockIndex); + account_balance_dfx : (AccountBalanceArgsDfx) -> (Tokens) query; + + // The following methods implement the ICRC-1 Token Standard. + // https://github.com/dfinity/ICRC-1/tree/main/standards/ICRC-1 + icrc1_name : () -> (text) query; + icrc1_symbol : () -> (text) query; + icrc1_decimals : () -> (nat8) query; + icrc1_metadata : () -> (vec record { text; Value }) query; + icrc1_total_supply : () -> (Icrc1Tokens) query; + icrc1_fee : () -> (Icrc1Tokens) query; + icrc1_minting_account : () -> (opt Account) query; + icrc1_balance_of : (Account) -> (Icrc1Tokens) query; + icrc1_transfer : (TransferArg) -> (Icrc1TransferResult); + icrc1_supported_standards : () -> (vec record { name : text; url : text }) query; + icrc2_approve : (ApproveArgs) -> (ApproveResult); + icrc2_allowance : (AllowanceArgs) -> (Allowance) query; + icrc2_transfer_from : (TransferFromArgs) -> (TransferFromResult); } diff --git a/ic/testdata/did/icrc1.did b/ic/testdata/did/icrc1.did index 3e9f478..f9307ca 100644 --- a/ic/testdata/did/icrc1.did +++ b/ic/testdata/did/icrc1.did @@ -1,5 +1,3 @@ -// SOURCE: https://github.com/dfinity/ICRC-1/blob/e98895acb70f8f836d7b63e47ac92552e1ceff79/standards/ICRC-1/ICRC-1.did - // Number of nanoseconds since the UNIX epoch in UTC timezone. type Timestamp = nat64; diff --git a/ic/testdata/did/wallet.did b/ic/testdata/did/wallet.did index e6c0d8a..7b0ec6b 100644 --- a/ic/testdata/did/wallet.did +++ b/ic/testdata/did/wallet.did @@ -1,72 +1,185 @@ -// SOURCE: https://github.com/dfinity/sdk/blob/c1ecdaad0257e79cedbc19c485b86021831fa4b7/src/distributed/assetstorage.did +type EventKind = variant { + CyclesSent: record { + to: principal; + amount: nat64; + refund: nat64; + }; + CyclesReceived: record { + from: principal; + amount: nat64; + memo: opt text; + }; + AddressAdded: record { + id: principal; + name: opt text; + role: Role; + }; + AddressRemoved: record { + id: principal; + }; + CanisterCreated: record { + canister: principal; + cycles: nat64; + }; + CanisterCalled: record { + canister: principal; + method_name: text; + cycles: nat64; + }; + WalletDeployed: record { + canister: principal; + } +}; -type BatchId = nat; -type ChunkId = nat; -type Key = text; -type Time = int; +type EventKind128 = variant { + CyclesSent: record { + to: principal; + amount: nat; + refund: nat; + }; + CyclesReceived: record { + from: principal; + amount: nat; + memo: opt text; + }; + AddressAdded: record { + id: principal; + name: opt text; + role: Role; + }; + AddressRemoved: record { + id: principal; + }; + CanisterCreated: record { + canister: principal; + cycles: nat; + }; + CanisterCalled: record { + canister: principal; + method_name: text; + cycles: nat; + }; + WalletDeployed: record { + canister: principal; + }; +}; -type CreateAssetArguments = record { - key: Key; - content_type: text; - max_age: opt nat64; - headers: opt vec HeaderField; - enable_aliasing: opt bool; - allow_raw_access: opt bool; +type Event = record { + id: nat32; + timestamp: nat64; + kind: EventKind; }; -// Add or change content for an asset, by content encoding -type SetAssetContentArguments = record { - key: Key; - content_encoding: text; - chunk_ids: vec ChunkId; - sha256: opt blob; +type Event128 = record { + id: nat32; + timestamp: nat64; + kind: EventKind128; }; -// Remove content for an asset, by content encoding -type UnsetAssetContentArguments = record { - key: Key; - content_encoding: text; +type Role = variant { + Contact; + Custodian; + Controller; }; -// Delete an asset -type DeleteAssetArguments = record { - key: Key; +type Kind = variant { + Unknown; + User; + Canister; }; -// Reset everything -type ClearArguments = record {}; +// An entry in the address book. It must have an ID and a role. +type AddressEntry = record { + id: principal; + name: opt text; + kind: Kind; + role: Role; +}; -type BatchOperationKind = variant { - CreateAsset: CreateAssetArguments; - SetAssetContent: SetAssetContentArguments; +type ManagedCanisterInfo = record { + id: principal; + name: opt text; + created_at: nat64; +}; - SetAssetProperties: SetAssetPropertiesArguments; +type ManagedCanisterEventKind = variant { + CyclesSent: record { + amount: nat64; + refund: nat64; + }; + Called: record { + method_name: text; + cycles: nat64; + }; + Created: record { + cycles: nat64; + }; +}; - UnsetAssetContent: UnsetAssetContentArguments; - DeleteAsset: DeleteAssetArguments; +type ManagedCanisterEventKind128 = variant { + CyclesSent: record { + amount: nat; + refund: nat; + }; + Called: record { + method_name: text; + cycles: nat; + }; + Created: record { + cycles: nat; + }; +}; + +type ManagedCanisterEvent = record { + id: nat32; + timestamp: nat64; + kind: ManagedCanisterEventKind; +}; - Clear: ClearArguments; +type ManagedCanisterEvent128 = record { + id: nat32; + timestamp: nat64; + kind: ManagedCanisterEventKind128; }; -type CommitBatchArguments = record { - batch_id: BatchId; - operations: vec BatchOperationKind +type ReceiveOptions = record { + memo: opt text; }; -type CommitProposedBatchArguments = record { - batch_id: BatchId; - evidence: blob; +type WalletResultCreate = variant { + Ok : record { canister_id: principal }; + Err: text; }; -type ComputeEvidenceArguments = record { - batch_id: BatchId; - max_iterations: opt nat16 +type WalletResult = variant { + Ok : null; + Err : text; }; -type DeleteBatchArguments = record { - batch_id: BatchId; +type WalletResultCall = variant { + Ok : record { return: blob }; + Err : text; }; +type CanisterSettings = record { + controller: opt principal; + controllers: opt vec principal; + compute_allocation: opt nat; + memory_allocation: opt nat; + freezing_threshold: opt nat; +}; + +type CreateCanisterArgs = record { + cycles: nat64; + settings: CanisterSettings; +}; + +type CreateCanisterArgs128 = record { + cycles: nat; + settings: CanisterSettings; +}; + +// Assets type HeaderField = record { text; text; }; type HttpRequest = record { @@ -74,7 +187,6 @@ type HttpRequest = record { url: text; headers: vec HeaderField; body: blob; - certificate_version: opt nat16; }; type HttpResponse = record { @@ -86,145 +198,85 @@ type HttpResponse = record { type StreamingCallbackHttpResponse = record { body: blob; - token: opt StreamingCallbackToken; + token: opt Token; }; -type StreamingCallbackToken = record { - key: Key; - content_encoding: text; - index: nat; - sha256: opt blob; -}; +type Token = record {}; type StreamingStrategy = variant { Callback: record { - callback: func (StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; - token: StreamingCallbackToken; + callback: func (Token) -> (StreamingCallbackHttpResponse) query; + token: Token; }; }; -type SetAssetPropertiesArguments = record { - key: Key; - max_age: opt opt nat64; - headers: opt opt vec HeaderField; - allow_raw_access: opt opt bool; - is_aliased: opt opt bool; -}; - -type Permission = variant { - Commit; - ManagePermissions; - Prepare; -}; - -type GrantPermission = record { - to_principal: principal; - permission: Permission; -}; -type RevokePermission = record { - of_principal: principal; - permission: Permission; -}; -type ListPermitted = record { permission: Permission }; - -type ValidationResult = variant { Ok : text; Err : text }; - -service: { - api_version: () -> (nat16) query; - - get: (record { - key: Key; - accept_encodings: vec text; - }) -> (record { - content: blob; // may be the entirety of the content, or just chunk index 0 - content_type: text; - content_encoding: text; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - total_length: nat; // all chunks except last have size == content.size() - }) query; - - // if get() returned chunks > 1, call this to retrieve them. - // chunks may or may not be split up at the same boundaries as presented to create_chunk(). - get_chunk: (record { - key: Key; - content_encoding: text; - index: nat; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - }) -> (record { content: blob }) query; - - list : (record {}) -> (vec record { - key: Key; - content_type: text; - encodings: vec record { - content_encoding: text; - sha256: opt blob; // sha256 of entire asset encoding, calculated by dfx and passed in SetAssetContentArguments - length: nat; // Size of this encoding's blob. Calculated when uploading assets. - modified: Time; - }; - }) query; - - certified_tree : (record {}) -> (record { - certificate: blob; - tree: blob; - }) query; - - create_batch : (record {}) -> (record { batch_id: BatchId }); +service : { + wallet_api_version: () -> (text) query; - create_chunk: (record { batch_id: BatchId; content: blob }) -> (record { chunk_id: ChunkId }); + // Wallet Name + name: () -> (opt text) query; + set_name: (text) -> (); - // Perform all operations successfully, or reject - commit_batch: (CommitBatchArguments) -> (); + // Controller Management + get_controllers: () -> (vec principal) query; + add_controller: (principal) -> (); + remove_controller: (principal) -> (WalletResult); - // Save the batch operations for later commit - propose_commit_batch: (CommitBatchArguments) -> (); - - // Given a batch already proposed, perform all operations successfully, or reject - commit_proposed_batch: (CommitProposedBatchArguments) -> (); - - // Compute a hash over the CommitBatchArguments. Call until it returns Some(evidence). - compute_evidence: (ComputeEvidenceArguments) -> (opt blob); - - // Delete a batch that has been created, or proposed for commit, but not yet committed - delete_batch: (DeleteBatchArguments) -> (); + // Custodian Management + get_custodians: () -> (vec principal) query; + authorize: (principal) -> (); + deauthorize: (principal) -> (WalletResult); - create_asset: (CreateAssetArguments) -> (); - set_asset_content: (SetAssetContentArguments) -> (); - unset_asset_content: (UnsetAssetContentArguments) -> (); + // Cycle Management + wallet_balance: () -> (record { amount: nat64 }) query; + wallet_balance128: () -> (record { amount: nat }) query; + wallet_send: (record { canister: principal; amount: nat64 }) -> (WalletResult); + wallet_send128: (record { canister: principal; amount: nat }) -> (WalletResult); + wallet_receive: (opt ReceiveOptions) -> (); // Endpoint for receiving cycles. - delete_asset: (DeleteAssetArguments) -> (); + // Managing canister + wallet_create_canister: (CreateCanisterArgs) -> (WalletResultCreate); + wallet_create_canister128: (CreateCanisterArgs128) -> (WalletResultCreate); - clear: (ClearArguments) -> (); + wallet_create_wallet: (CreateCanisterArgs) -> (WalletResultCreate); + wallet_create_wallet128: (CreateCanisterArgs128) -> (WalletResultCreate); - // Single call to create an asset with content for a single content encoding that - // fits within the message ingress limit. - store: (record { - key: Key; - content_type: text; - content_encoding: text; - content: blob; - sha256: opt blob + wallet_store_wallet_wasm: (record { + wasm_module: blob; }) -> (); + // Call Forwarding + wallet_call: (record { + canister: principal; + method_name: text; + args: blob; + cycles: nat64; + }) -> (WalletResultCall); + wallet_call128: (record { + canister: principal; + method_name: text; + args: blob; + cycles: nat; + }) -> (WalletResultCall); + + // Address book + add_address: (address: AddressEntry) -> (); + list_addresses: () -> (vec AddressEntry) query; + remove_address: (address: principal) -> (WalletResult); + + // Events + // If `from` is not specified, it will start 20 from the end; if `to` is not specified, it will stop at the end + get_events: (opt record { from: opt nat32; to: opt nat32; }) -> (vec Event) query; + get_events128: (opt record { from: opt nat32; to: opt nat32; }) -> (vec Event128) query; + get_chart: (opt record { count: opt nat32; precision: opt nat64; } ) -> (vec record { nat64; nat64; }) query; + + // Managed canisters + list_managed_canisters: (record { from: opt nat32; to: opt nat32; }) -> (vec ManagedCanisterInfo, nat32) query; + // If `from` is not specified, it will start 20 from the end; if `to` is not specified, it will stop at the end + get_managed_canister_events: (record { canister: principal; from: opt nat32; to: opt nat32; }) -> (opt vec ManagedCanisterEvent) query; + get_managed_canister_events128: (record { canister: principal; from: opt nat32; to: opt nat32; }) -> (opt vec ManagedCanisterEvent128) query; + set_short_name: (principal, opt text) -> (opt ManagedCanisterInfo); + + // Assets http_request: (request: HttpRequest) -> (HttpResponse) query; - http_request_streaming_callback: (token: StreamingCallbackToken) -> (opt StreamingCallbackHttpResponse) query; - - authorize: (principal) -> (); - deauthorize: (principal) -> (); - list_authorized: () -> (vec principal) query; - grant_permission: (GrantPermission) -> (); - revoke_permission: (RevokePermission) -> (); - list_permitted: (ListPermitted) -> (vec principal) query; - take_ownership: () -> (); - - get_asset_properties : (key: Key) -> (record { - max_age: opt nat64; - headers: opt vec HeaderField; - allow_raw_access: opt bool; - is_aliased: opt bool; } ) query; - set_asset_properties: (SetAssetPropertiesArguments) -> (); - - validate_grant_permission: (GrantPermission) -> (ValidationResult); - validate_revoke_permission: (RevokePermission) -> (ValidationResult); - validate_take_ownership: () -> (ValidationResult); - validate_commit_proposed_batch: (CommitProposedBatchArguments) -> (ValidationResult); } diff --git a/ic/testdata/gen.go b/ic/testdata/gen.go index 182e74c..bf86121 100644 --- a/ic/testdata/gen.go +++ b/ic/testdata/gen.go @@ -1,10 +1,13 @@ package main import ( + "bytes" "embed" "fmt" "github.com/aviate-labs/agent-go/gen" + "io" "log" + "net/http" "os" "strings" "unicode" @@ -15,7 +18,66 @@ var ( dids embed.FS ) +func checkLatest() error { + for _, f := range []struct { + filepath string + remote string + }{ + { + filepath: "ic/testdata/did/assetstorage.did", + remote: "https://raw.githubusercontent.com/dfinity/sdk/master/src/distributed/assetstorage.did", + }, + { + filepath: "ic/testdata/did/cmc.did", + remote: "https://raw.githubusercontent.com/dfinity/ic/master/rs/nns/cmc/cmc.did", + }, + { + filepath: "ic/testdata/did/ic.did", + remote: "https://raw.githubusercontent.com/dfinity/interface-spec/master/spec/_attachments/ic.did", + }, + { + filepath: "ic/testdata/did/icparchive.did", + remote: "https://raw.githubusercontent.com/dfinity/ic/master/rs/rosetta-api/icp_ledger/ledger_archive.did", + }, + { + filepath: "ic/testdata/did/icpledger.did", + remote: "https://raw.githubusercontent.com/dfinity/ic/master/rs/rosetta-api/icp_ledger/ledger.did", + }, + { + filepath: "ic/testdata/did/icrc1.did", + remote: "https://raw.githubusercontent.com/dfinity/ICRC-1/master/standards/ICRC-1/ICRC-1.did", + }, + { + filepath: "ic/testdata/did/wallet.did", + remote: "https://raw.githubusercontent.com/dfinity/sdk/master/src/distributed/wallet.did", + }, + } { + raw, err := http.Get(f.remote) + if err != nil { + return err + } + remoteDID, err := io.ReadAll(raw.Body) + if err != nil { + return err + } + localDID, err := os.ReadFile(f.filepath) + if err != nil { + return err + } + if bytes.Compare(remoteDID, localDID) != 0 { + if err := os.WriteFile(f.filepath, remoteDID, os.ModePerm); err != nil { + return err + } + } + } + return nil +} + func main() { + if err := checkLatest(); err != nil { + log.Panic(err) + } + entries, _ := dids.ReadDir("did") for _, entry := range entries { name := strings.TrimSuffix(entry.Name(), ".did") diff --git a/ic/wallet/actor.mo b/ic/wallet/actor.mo index 0f31de4..d676607 100755 --- a/ic/wallet/actor.mo +++ b/ic/wallet/actor.mo @@ -3,104 +3,101 @@ import T "types"; import { principalOfBlob } = "mo:⛔"; -actor class wallet() : async actor {} { - public query func api_version() : async (Nat16) { - (38652) +actor class _wallet() : async actor {} { + public query func wallet_api_version() : async (Text) { + ("12501942321308663592") }; - public query func get(arg0 : { key : T.Key; accept_encodings : [Text] }) : async ({ content : Blob; content_type : Text; content_encoding : Text; sha256 : ?Blob; total_length : Nat }) { - ({ content = "x287F06984DD27FAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B"; content_type = "13842832487040869502"; content_encoding = "9207851698408531338"; sha256 = ?"x7B1BCA3A098396CB5C620BF809689EE32C89B845322F01379CB07CF44C41BFC6"; total_length = 15226500214129345624 }) + public query func name() : async (?Text) { + (?"12501942321308663592") }; - public query func get_chunk(arg0 : { key : T.Key; content_encoding : Text; index : Nat; sha256 : ?Blob }) : async ({ content : Blob }) { - ({ content = "x287F06984DD27FAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B" }) + public shared func set_name(_arg0 : Text) : async () { + () }; - public query func list(arg0 : { }) : async ([{ key : T.Key; content_type : Text; encodings : [{ content_encoding : Text; sha256 : ?Blob; length : Nat; modified : T.Time }] }]) { - ([ { key = "7404491806706941354"; content_type = "10285557685837050495"; encodings = [ { content_encoding = "6353661455985592489"; sha256 = ?"x7EE44EF3CD9E1B8A251E9C55DCC87B1BCA3A098396CB5C620BF809689EE32C89"; length = 8643670682807763247; modified = 10342561696286982476 }, { content_encoding = "15226500214129345624"; sha256 = ?"x9614DC1B2711874D3E6FE25E3A8F72C632E3513A5F5E92AF8BF9CEF5969C068E"; length = 9589032066643545779; modified = 5539044620517515997 }, { content_encoding = "1923756884486142631"; sha256 = ?"x1D8C751BCB77BB0746C29470D17024B544336AECB870087656C06A2339BC49BC"; length = 2653383589281119158; modified = 10428971936530044628 }, { content_encoding = "7786994376157721829"; sha256 = ?"x84C261981FA00B16B635580B470ABE60197656644765CA6F5488D5E4A7A530B0"; length = 14150654805229633014; modified = 8157667525784526154 }, { content_encoding = "13234612580036397592"; sha256 = ?"x7A74B6930B2F2C16BB7A5A5071CC53F4577AC3864C4C583CF068857E9B69403F"; length = 2326156757508477903; modified = 13534220423551798816 }, { content_encoding = "17298645943394680105"; sha256 = ?"x1D71DBBBA4BD4FE4384BFDF2965F7F9ED9195ABCD5F15EA919870B1305B6FBEA"; length = 7193462899950823818; modified = 5372797585040004340 } ] }, { key = "8405210950166936129"; content_type = "13851258177473485163"; encodings = [ { content_encoding = "10165017509674453068"; sha256 = ?"x3E35C32D75D3C4784E82EAAF4E3162231C6ED7DC02090A31DDC9A189CA85FAFB"; length = 9076123652376596064; modified = 13788132375959277386 }, { content_encoding = "10818449170260277067"; sha256 = ?"xC0FBF50AE9F93AF1C4CDDD15F8511661030D29CA18CD734D791C7A26999F921C"; length = 15936827406159436595; modified = 1077672755291584990 }, { content_encoding = "16003893191925063214"; sha256 = ?"x3C85ECB90741D9ACC5033E6346556F9DFB82D7E06BDB7DA0FCB214B94F717AD2"; length = 4730893632513896881; modified = 13772962967874715627 }, { content_encoding = "6859593430023241065"; sha256 = ?"x76D889905ABF73E5097448C3AC58856465CC7F7283739F38CCD7E97B29B53311"; length = 14445486139781075996; modified = 9938180212790421664 } ] }, { key = "9101864922507107316"; content_type = "1536328808225679195"; encodings = [ { content_encoding = "13231498797124074758"; sha256 = ?"x94F5F07C5016E89FF5A0DD8105640A16418B9B471476359529B6F56DB15E24BB"; length = 17387340558135946525; modified = 11977568734881657944 } ] }, { key = "8679673755513378830"; content_type = "10491644904757661466"; encodings = [ { content_encoding = "1562262160616910768"; sha256 = ?"x5ACC94A73AF8C7183D527B00A4376396249EB14513AB937A9AC8FCB67AB53FB8"; length = 7727076029448843586; modified = 2343418153347362432 }, { content_encoding = "7201485676058401090"; sha256 = ?"x57331E8D5B453222B9C7CC43D1DC5BBA2095F24CB92AB1930CCAEA0285B7A568"; length = 8789469013259815246; modified = 14122149734664040066 } ] } ]) + public query func get_controllers() : async ([Principal]) { + ([ principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3"), principalOfBlob("x8A251E9C55DCC87B1BCA3A098396CB5C620BF809689EE32C89B845322F01379C"), principalOfBlob("x4C41BFC610298858C4967345654F9614DC1B2711874D3E6FE25E3A8F72C632E3"), principalOfBlob("x5E92AF8BF9CEF5969C068EE637EBB34E1E18DC1513DD22FC38BCA3DEA73A02A6") ]) }; - public query func certified_tree(arg0 : { }) : async ({ certificate : Blob; tree : Blob }) { - ({ certificate = "x287F06984DD27FAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B"; tree = "x7EE44EF3CD9E1B8A251E9C55DCC87B1BCA3A098396CB5C620BF809689EE32C89" }) + public shared func add_controller(_arg0 : Principal) : async () { + () }; - public shared func create_batch(arg0 : { }) : async ({ batch_id : T.BatchId }) { - ({ batch_id = 12501942321308663592 }) + public shared func remove_controller(_arg0 : Principal) : async (T.WalletResult) { + (#Ok(())) }; - public shared func create_chunk(arg0 : { batch_id : T.BatchId; content : Blob }) : async ({ chunk_id : T.ChunkId }) { - ({ chunk_id = 12501942321308663592 }) + public query func get_custodians() : async ([Principal]) { + ([ principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3"), principalOfBlob("x8A251E9C55DCC87B1BCA3A098396CB5C620BF809689EE32C89B845322F01379C"), principalOfBlob("x4C41BFC610298858C4967345654F9614DC1B2711874D3E6FE25E3A8F72C632E3"), principalOfBlob("x5E92AF8BF9CEF5969C068EE637EBB34E1E18DC1513DD22FC38BCA3DEA73A02A6") ]) }; - public shared func commit_batch(arg0 : T.CommitBatchArguments) : async () { + public shared func authorize(_arg0 : Principal) : async () { () }; - public shared func propose_commit_batch(arg0 : T.CommitBatchArguments) : async () { - () + public shared func deauthorize(_arg0 : Principal) : async (T.WalletResult) { + (#Ok(())) }; - public shared func commit_proposed_batch(arg0 : T.CommitProposedBatchArguments) : async () { - () + public query func wallet_balance() : async ({ amount : Nat64 }) { + ({ amount = 12501942321308663592 }) }; - public shared func compute_evidence(arg0 : T.ComputeEvidenceArguments) : async (?Blob) { - (?"x287F06984DD27FAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B") + public query func wallet_balance128() : async ({ amount : Nat }) { + ({ amount = 12501942321308663592 }) }; - public shared func delete_batch(arg0 : T.DeleteBatchArguments) : async () { - () + public shared func wallet_send(_arg0 : { canister : Principal; amount : Nat64 }) : async (T.WalletResult) { + (#Ok(())) }; - public shared func create_asset(arg0 : T.CreateAssetArguments) : async () { - () + public shared func wallet_send128(_arg0 : { canister : Principal; amount : Nat }) : async (T.WalletResult) { + (#Ok(())) }; - public shared func set_asset_content(arg0 : T.SetAssetContentArguments) : async () { + public shared func wallet_receive(_arg0 : ?T.ReceiveOptions) : async () { () }; - public shared func unset_asset_content(arg0 : T.UnsetAssetContentArguments) : async () { - () + public shared func wallet_create_canister(_arg0 : T.CreateCanisterArgs) : async (T.WalletResultCreate) { + (#Ok({ canister_id = principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3") })) }; - public shared func delete_asset(arg0 : T.DeleteAssetArguments) : async () { - () + public shared func wallet_create_canister128(_arg0 : T.CreateCanisterArgs128) : async (T.WalletResultCreate) { + (#Ok({ canister_id = principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3") })) }; - public shared func clear(arg0 : T.ClearArguments) : async () { - () + public shared func wallet_create_wallet(_arg0 : T.CreateCanisterArgs) : async (T.WalletResultCreate) { + (#Ok({ canister_id = principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3") })) }; - public shared func store(arg0 : { key : T.Key; content_type : Text; content_encoding : Text; content : Blob; sha256 : ?Blob }) : async () { - () - }; - public query func http_request(arg0 : T.HttpRequest) : async (T.HttpResponse) { - ({ status_code = 38652; headers = [ ( "10285557685837050495", "16344125491934207374" ), ( "6353661455985592489", "13842832487040869502" ), ( "9207851698408531338", "7031951943849876347" ), ( "10982038652290489547", "12408056582236857246" ) ]; body = "x2F01379CB07CF44C41BFC610298858C4967345654F9614DC1B2711874D3E6FE2"; streaming_strategy = ?#Callback({ callback = { /* func */ }; token = { key = "6194084433703703134"; content_encoding = "4389663725167484054"; index = 9589032066643545779; sha256 = ?"xDD22FC38BCA3DEA73A02A6B18EB21D8C751BCB77BB0746C29470D17024B54433" } }) }) - }; - public query func http_request_streaming_callback(arg0 : T.StreamingCallbackToken) : async (?T.StreamingCallbackHttpResponse) { - (?{ body = "x287F06984DD27FAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B"; token = ?{ key = "13842832487040869502"; content_encoding = "9207851698408531338"; index = 7031951943849876347; sha256 = ?"xCB5C620BF809689EE32C89B845322F01379CB07CF44C41BFC610298858C49673" } }) + public shared func wallet_create_wallet128(_arg0 : T.CreateCanisterArgs128) : async (T.WalletResultCreate) { + (#Ok({ canister_id = principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3") })) }; - public shared func authorize(arg0 : Principal) : async () { + public shared func wallet_store_wallet_wasm(_arg0 : { wasm_module : Blob }) : async () { () }; - public shared func deauthorize(arg0 : Principal) : async () { - () + public shared func wallet_call(_arg0 : { canister : Principal; method_name : Text; args : Blob; cycles : Nat64 }) : async (T.WalletResultCall) { + (#Ok({ return = "xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3" })) }; - public query func list_authorized() : async ([Principal]) { - ([ principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3"), principalOfBlob("x8A251E9C55DCC87B1BCA3A098396CB5C620BF809689EE32C89B845322F01379C"), principalOfBlob("x4C41BFC610298858C4967345654F9614DC1B2711874D3E6FE25E3A8F72C632E3"), principalOfBlob("x5E92AF8BF9CEF5969C068EE637EBB34E1E18DC1513DD22FC38BCA3DEA73A02A6") ]) + public shared func wallet_call128(_arg0 : { canister : Principal; method_name : Text; args : Blob; cycles : Nat }) : async (T.WalletResultCall) { + (#Ok({ return = "xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3" })) }; - public shared func grant_permission(arg0 : T.GrantPermission) : async () { + public shared func add_address(_arg0 : T.AddressEntry) : async () { () }; - public shared func revoke_permission(arg0 : T.RevokePermission) : async () { - () + public query func list_addresses() : async ([T.AddressEntry]) { + ([ { id = principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3"); name = ?"9207851698408531338"; kind = #Canister; role = #Contact }, { id = principalOfBlob("x9EE32C89B845322F01379CB07CF44C41BFC610298858C4967345654F9614DC1B"); name = ?"18342943986503597645"; kind = #User; role = #Custodian }, { id = principalOfBlob("x969C068EE637EBB34E1E18DC1513DD22FC38BCA3DEA73A02A6B18EB21D8C751B"); name = ?"15380023008932546055"; kind = #User; role = #Controller }, { id = principalOfBlob("x39BC49BC882A10B6BBF3F350B6D2D41664A1B826BBE574D8BA20F61084C26198"); name = ?"11315935127771919894"; kind = #Unknown; role = #Controller } ]) }; - public query func list_permitted(arg0 : T.ListPermitted) : async ([Principal]) { - ([ principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3"), principalOfBlob("x8A251E9C55DCC87B1BCA3A098396CB5C620BF809689EE32C89B845322F01379C"), principalOfBlob("x4C41BFC610298858C4967345654F9614DC1B2711874D3E6FE25E3A8F72C632E3"), principalOfBlob("x5E92AF8BF9CEF5969C068EE637EBB34E1E18DC1513DD22FC38BCA3DEA73A02A6") ]) + public shared func remove_address(_arg0 : Principal) : async (T.WalletResult) { + (#Ok(())) }; - public shared func take_ownership() : async () { - () + public query func get_events(_arg0 : ?{ from : ?Nat32; to : ?Nat32 }) : async ([T.Event]) { + ([ { id = 2949695419; timestamp = 10285557685837050495; kind = #CyclesSent({ to = principalOfBlob("xA9C81C5B6EBD2C7EE44EF3CD9E1B8A251E9C55DCC87B1BCA3A098396CB5C620B"); amount = 12408056582236857246; refund = 8643670682807763247 }) }, { id = 1447520861; timestamp = 15226500214129345624; kind = #CanisterCalled({ canister = principalOfBlob("x4D3E6FE25E3A8F72C632E3513A5F5E92AF8BF9CEF5969C068EE637EBB34E1E18"); method_name = "5539044620517515997"; cycles = 1923756884486142631 }) }, { id = 2805007336; timestamp = 15380023008932546055; kind = #CyclesReceived({ from = principalOfBlob("x70087656C06A2339BC49BC882A10B6BBF3F350B6D2D41664A1B826BBE574D8BA"); amount = 7929607626476864132; memo = ?"11315935127771919894" }) }, { id = 1415628053; timestamp = 13683296349367290469; kind = #WalletDeployed({ canister = principalOfBlob("xF6FDE26C9239614A5D20BE64DB35184AFC8405CAAA7A74B6930B2F2C16BB7A5A") }) } ]) }; - public query func get_asset_properties(arg0 : T.Key) : async ({ max_age : ?Nat64; headers : ?[T.HeaderField]; allow_raw_access : ?Bool; is_aliased : ?Bool }) { - ({ max_age = ?12501942321308663592; headers = ?[ ( "10285557685837050495", "16344125491934207374" ), ( "6353661455985592489", "13842832487040869502" ), ( "9207851698408531338", "7031951943849876347" ), ( "10982038652290489547", "12408056582236857246" ) ]; allow_raw_access = ?false; is_aliased = ?true }) + public query func get_events128(_arg0 : ?{ from : ?Nat32; to : ?Nat32 }) : async ([T.Event128]) { + ([ { id = 2949695419; timestamp = 10285557685837050495; kind = #CyclesSent({ to = principalOfBlob("xA9C81C5B6EBD2C7EE44EF3CD9E1B8A251E9C55DCC87B1BCA3A098396CB5C620B"); amount = 12408056582236857246; refund = 8643670682807763247 }) }, { id = 1447520861; timestamp = 15226500214129345624; kind = #CanisterCalled({ canister = principalOfBlob("x4D3E6FE25E3A8F72C632E3513A5F5E92AF8BF9CEF5969C068EE637EBB34E1E18"); method_name = "5539044620517515997"; cycles = 1923756884486142631 }) }, { id = 2805007336; timestamp = 15380023008932546055; kind = #CyclesReceived({ from = principalOfBlob("x70087656C06A2339BC49BC882A10B6BBF3F350B6D2D41664A1B826BBE574D8BA"); amount = 7929607626476864132; memo = ?"11315935127771919894" }) }, { id = 1415628053; timestamp = 13683296349367290469; kind = #WalletDeployed({ canister = principalOfBlob("xF6FDE26C9239614A5D20BE64DB35184AFC8405CAAA7A74B6930B2F2C16BB7A5A") }) } ]) }; - public shared func set_asset_properties(arg0 : T.SetAssetPropertiesArguments) : async () { - () + public query func get_chart(_arg0 : ?{ count : ?Nat32; precision : ?Nat64 }) : async ([(Nat64, Nat64)]) { + ([ ( 7404491806706941354, 10285557685837050495 ), ( 16344125491934207374, 6353661455985592489 ), ( 13842832487040869502, 9207851698408531338 ), ( 7031951943849876347, 10982038652290489547 ) ]) + }; + public query func list_managed_canisters(_arg0 : { from : ?Nat32; to : ?Nat32 }) : async ([T.ManagedCanisterInfo], Nat32) { + ([ { id = principalOfBlob("xAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B6EBD2C7EE44EF3"); name = ?"9207851698408531338"; created_at = 7031951943849876347 }, { id = principalOfBlob("xCB5C620BF809689EE32C89B845322F01379CB07CF44C41BFC610298858C49673"); name = ?"8829044454151951510"; created_at = 18342943986503597645 }, { id = principalOfBlob("x72C632E3513A5F5E92AF8BF9CEF5969C068EE637EBB34E1E18DC1513DD22FC38"); name = ?"1923756884486142631"; created_at = 10068773106139630621 }, { id = principalOfBlob("x0746C29470D17024B544336AECB870087656C06A2339BC49BC882A10B6BBF3F3"); name = ?"10428971936530044628"; created_at = 7786994376157721829 } ], 107831972) }; - public shared func validate_grant_permission(arg0 : T.GrantPermission) : async (T.ValidationResult) { - (#Ok("7404491806706941354")) + public query func get_managed_canister_events(_arg0 : { canister : Principal; from : ?Nat32; to : ?Nat32 }) : async (?[T.ManagedCanisterEvent]) { + (?[ { id = 2949695419; timestamp = 10285557685837050495; kind = #Created({ cycles = 6353661455985592489 }) }, { id = 3010102092; timestamp = 9207851698408531338; kind = #Created({ cycles = 10982038652290489547 }) }, { id = 895428951; timestamp = 8643670682807763247; kind = #CyclesSent({ amount = 15226500214129345624; refund = 8829044454151951510 }) }, { id = 3774773420; timestamp = 2188532067303868018; kind = #Called({ method_name = "4389663725167484054"; cycles = 9589032066643545779 }) } ]) }; - public shared func validate_revoke_permission(arg0 : T.RevokePermission) : async (T.ValidationResult) { - (#Ok("7404491806706941354")) + public query func get_managed_canister_events128(_arg0 : { canister : Principal; from : ?Nat32; to : ?Nat32 }) : async (?[T.ManagedCanisterEvent128]) { + (?[ { id = 2949695419; timestamp = 10285557685837050495; kind = #Created({ cycles = 6353661455985592489 }) }, { id = 3010102092; timestamp = 9207851698408531338; kind = #Created({ cycles = 10982038652290489547 }) }, { id = 895428951; timestamp = 8643670682807763247; kind = #CyclesSent({ amount = 15226500214129345624; refund = 8829044454151951510 }) }, { id = 3774773420; timestamp = 2188532067303868018; kind = #Called({ method_name = "4389663725167484054"; cycles = 9589032066643545779 }) } ]) }; - public shared func validate_take_ownership() : async (T.ValidationResult) { - (#Ok("7404491806706941354")) + public shared func set_short_name(_arg0 : Principal, _arg1 : ?Text) : async (?T.ManagedCanisterInfo) { + (?{ id = principalOfBlob("x287F06984DD27FAABD0E49110AC27F321B5538A4BD8E1D253F8AFFD1A9C81C5B"); name = ?"13842832487040869502"; created_at = 9207851698408531338 }) }; - public shared func validate_commit_proposed_batch(arg0 : T.CommitProposedBatchArguments) : async (T.ValidationResult) { - (#Ok("7404491806706941354")) + public query func http_request(_arg0 : T.HttpRequest) : async (T.HttpResponse) { + ({ status_code = 38652; headers = [ ( "10285557685837050495", "16344125491934207374" ), ( "6353661455985592489", "13842832487040869502" ), ( "9207851698408531338", "7031951943849876347" ), ( "10982038652290489547", "12408056582236857246" ) ]; body = "x2F01379CB07CF44C41BFC610298858C4967345654F9614DC1B2711874D3E6FE2"; streaming_strategy = ?#Callback({ callback = { /* func */ }; token = { } }) }) }; } diff --git a/ic/wallet/agent.go b/ic/wallet/agent.go index d47c529..18cecb8 100755 --- a/ic/wallet/agent.go +++ b/ic/wallet/agent.go @@ -8,6 +8,13 @@ import ( "github.com/aviate-labs/agent-go/principal" ) +type AddressEntry struct { + Id principal.Principal `ic:"id" json:"id"` + Name *string `ic:"name,omitempty" json:"name,omitempty"` + Kind Kind `ic:"kind" json:"kind"` + Role Role `ic:"role" json:"role"` +} + // Agent is a client for the "wallet" canister. type Agent struct { a *agent.Agent @@ -26,18 +33,30 @@ func NewAgent(canisterId principal.Principal, config agent.Config) (*Agent, erro }, nil } -// ApiVersion calls the "api_version" method on the "wallet" canister. -func (a Agent) ApiVersion() (*uint16, error) { - var r0 uint16 - if err := a.a.Query( +// AddAddress calls the "add_address" method on the "wallet" canister. +func (a Agent) AddAddress(address AddressEntry) error { + if err := a.a.Call( a.canisterId, - "api_version", + "add_address", + []any{address}, []any{}, - []any{&r0}, ); err != nil { - return nil, err + return err } - return &r0, nil + return nil +} + +// AddController calls the "add_controller" method on the "wallet" canister. +func (a Agent) AddController(arg0 principal.Principal) error { + if err := a.a.Call( + a.canisterId, + "add_controller", + []any{arg0}, + []any{}, + ); err != nil { + return err + } + return nil } // Authorize calls the "authorize" method on the "wallet" canister. @@ -53,19 +72,12 @@ func (a Agent) Authorize(arg0 principal.Principal) error { return nil } -// CertifiedTree calls the "certified_tree" method on the "wallet" canister. -func (a Agent) CertifiedTree(arg0 struct { -}) (*struct { - Certificate []byte `ic:"certificate" json:"certificate"` - Tree []byte `ic:"tree" json:"tree"` -}, error) { - var r0 struct { - Certificate []byte `ic:"certificate" json:"certificate"` - Tree []byte `ic:"tree" json:"tree"` - } - if err := a.a.Query( +// Deauthorize calls the "deauthorize" method on the "wallet" canister. +func (a Agent) Deauthorize(arg0 principal.Principal) (*WalletResult, error) { + var r0 WalletResult + if err := a.a.Call( a.canisterId, - "certified_tree", + "deauthorize", []any{arg0}, []any{&r0}, ); err != nil { @@ -74,51 +86,66 @@ func (a Agent) CertifiedTree(arg0 struct { return &r0, nil } -// Clear calls the "clear" method on the "wallet" canister. -func (a Agent) Clear(arg0 ClearArguments) error { - if err := a.a.Call( +// GetChart calls the "get_chart" method on the "wallet" canister. +func (a Agent) GetChart(arg0 *struct { + Count *uint32 `ic:"count,omitempty" json:"count,omitempty"` + Precision *uint64 `ic:"precision,omitempty" json:"precision,omitempty"` +}) (*[]struct { + Field0 uint64 `ic:"0" json:"0"` + Field1 uint64 `ic:"1" json:"1"` +}, error) { + var r0 []struct { + Field0 uint64 `ic:"0" json:"0"` + Field1 uint64 `ic:"1" json:"1"` + } + if err := a.a.Query( a.canisterId, - "clear", + "get_chart", []any{arg0}, - []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// CommitBatch calls the "commit_batch" method on the "wallet" canister. -func (a Agent) CommitBatch(arg0 CommitBatchArguments) error { - if err := a.a.Call( +// GetControllers calls the "get_controllers" method on the "wallet" canister. +func (a Agent) GetControllers() (*[]principal.Principal, error) { + var r0 []principal.Principal + if err := a.a.Query( a.canisterId, - "commit_batch", - []any{arg0}, + "get_controllers", []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// CommitProposedBatch calls the "commit_proposed_batch" method on the "wallet" canister. -func (a Agent) CommitProposedBatch(arg0 CommitProposedBatchArguments) error { - if err := a.a.Call( +// GetCustodians calls the "get_custodians" method on the "wallet" canister. +func (a Agent) GetCustodians() (*[]principal.Principal, error) { + var r0 []principal.Principal + if err := a.a.Query( a.canisterId, - "commit_proposed_batch", - []any{arg0}, + "get_custodians", []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// ComputeEvidence calls the "compute_evidence" method on the "wallet" canister. -func (a Agent) ComputeEvidence(arg0 ComputeEvidenceArguments) (**[]byte, error) { - var r0 *[]byte - if err := a.a.Call( +// GetEvents calls the "get_events" method on the "wallet" canister. +func (a Agent) GetEvents(arg0 *struct { + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` +}) (*[]Event, error) { + var r0 []Event + if err := a.a.Query( a.canisterId, - "compute_evidence", + "get_events", []any{arg0}, []any{&r0}, ); err != nil { @@ -127,30 +154,33 @@ func (a Agent) ComputeEvidence(arg0 ComputeEvidenceArguments) (**[]byte, error) return &r0, nil } -// CreateAsset calls the "create_asset" method on the "wallet" canister. -func (a Agent) CreateAsset(arg0 CreateAssetArguments) error { - if err := a.a.Call( +// GetEvents128 calls the "get_events128" method on the "wallet" canister. +func (a Agent) GetEvents128(arg0 *struct { + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` +}) (*[]Event128, error) { + var r0 []Event128 + if err := a.a.Query( a.canisterId, - "create_asset", + "get_events128", []any{arg0}, - []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// CreateBatch calls the "create_batch" method on the "wallet" canister. -func (a Agent) CreateBatch(arg0 struct { -}) (*struct { - BatchId BatchId `ic:"batch_id" json:"batch_id"` -}, error) { - var r0 struct { - BatchId BatchId `ic:"batch_id" json:"batch_id"` - } - if err := a.a.Call( +// GetManagedCanisterEvents calls the "get_managed_canister_events" method on the "wallet" canister. +func (a Agent) GetManagedCanisterEvents(arg0 struct { + Canister principal.Principal `ic:"canister" json:"canister"` + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` +}) (**[]ManagedCanisterEvent, error) { + var r0 *[]ManagedCanisterEvent + if err := a.a.Query( a.canisterId, - "create_batch", + "get_managed_canister_events", []any{arg0}, []any{&r0}, ); err != nil { @@ -159,19 +189,16 @@ func (a Agent) CreateBatch(arg0 struct { return &r0, nil } -// CreateChunk calls the "create_chunk" method on the "wallet" canister. -func (a Agent) CreateChunk(arg0 struct { - BatchId BatchId `ic:"batch_id" json:"batch_id"` - Content []byte `ic:"content" json:"content"` -}) (*struct { - ChunkId ChunkId `ic:"chunk_id" json:"chunk_id"` -}, error) { - var r0 struct { - ChunkId ChunkId `ic:"chunk_id" json:"chunk_id"` - } - if err := a.a.Call( +// GetManagedCanisterEvents128 calls the "get_managed_canister_events128" method on the "wallet" canister. +func (a Agent) GetManagedCanisterEvents128(arg0 struct { + Canister principal.Principal `ic:"canister" json:"canister"` + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` +}) (**[]ManagedCanisterEvent128, error) { + var r0 *[]ManagedCanisterEvent128 + if err := a.a.Query( a.canisterId, - "create_chunk", + "get_managed_canister_events128", []any{arg0}, []any{&r0}, ); err != nil { @@ -180,67 +207,59 @@ func (a Agent) CreateChunk(arg0 struct { return &r0, nil } -// Deauthorize calls the "deauthorize" method on the "wallet" canister. -func (a Agent) Deauthorize(arg0 principal.Principal) error { - if err := a.a.Call( +// HttpRequest calls the "http_request" method on the "wallet" canister. +func (a Agent) HttpRequest(request HttpRequest) (*HttpResponse, error) { + var r0 HttpResponse + if err := a.a.Query( a.canisterId, - "deauthorize", - []any{arg0}, - []any{}, + "http_request", + []any{request}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// DeleteAsset calls the "delete_asset" method on the "wallet" canister. -func (a Agent) DeleteAsset(arg0 DeleteAssetArguments) error { - if err := a.a.Call( +// ListAddresses calls the "list_addresses" method on the "wallet" canister. +func (a Agent) ListAddresses() (*[]AddressEntry, error) { + var r0 []AddressEntry + if err := a.a.Query( a.canisterId, - "delete_asset", - []any{arg0}, + "list_addresses", []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// DeleteBatch calls the "delete_batch" method on the "wallet" canister. -func (a Agent) DeleteBatch(arg0 DeleteBatchArguments) error { - if err := a.a.Call( +// ListManagedCanisters calls the "list_managed_canisters" method on the "wallet" canister. +func (a Agent) ListManagedCanisters(arg0 struct { + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` +}) (*[]ManagedCanisterInfo, *uint32, error) { + var r0 []ManagedCanisterInfo + var r1 uint32 + if err := a.a.Query( a.canisterId, - "delete_batch", + "list_managed_canisters", []any{arg0}, - []any{}, + []any{&r0, &r1}, ); err != nil { - return err + return nil, nil, err } - return nil + return &r0, &r1, nil } -// Get calls the "get" method on the "wallet" canister. -func (a Agent) Get(arg0 struct { - Key Key `ic:"key" json:"key"` - AcceptEncodings []string `ic:"accept_encodings" json:"accept_encodings"` -}) (*struct { - Content []byte `ic:"content" json:"content"` - ContentType string `ic:"content_type" json:"content_type"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - TotalLength idl.Nat `ic:"total_length" json:"total_length"` -}, error) { - var r0 struct { - Content []byte `ic:"content" json:"content"` - ContentType string `ic:"content_type" json:"content_type"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - TotalLength idl.Nat `ic:"total_length" json:"total_length"` - } +// Name calls the "name" method on the "wallet" canister. +func (a Agent) Name() (**string, error) { + var r0 *string if err := a.a.Query( a.canisterId, - "get", - []any{arg0}, + "name", + []any{}, []any{&r0}, ); err != nil { return nil, err @@ -248,23 +267,13 @@ func (a Agent) Get(arg0 struct { return &r0, nil } -// GetAssetProperties calls the "get_asset_properties" method on the "wallet" canister. -func (a Agent) GetAssetProperties(key Key) (*struct { - MaxAge *uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` - Headers *[]HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` - AllowRawAccess *bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` - IsAliased *bool `ic:"is_aliased,omitempty" json:"is_aliased,omitempty"` -}, error) { - var r0 struct { - MaxAge *uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` - Headers *[]HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` - AllowRawAccess *bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` - IsAliased *bool `ic:"is_aliased,omitempty" json:"is_aliased,omitempty"` - } - if err := a.a.Query( +// RemoveAddress calls the "remove_address" method on the "wallet" canister. +func (a Agent) RemoveAddress(address principal.Principal) (*WalletResult, error) { + var r0 WalletResult + if err := a.a.Call( a.canisterId, - "get_asset_properties", - []any{key}, + "remove_address", + []any{address}, []any{&r0}, ); err != nil { return nil, err @@ -272,21 +281,12 @@ func (a Agent) GetAssetProperties(key Key) (*struct { return &r0, nil } -// GetChunk calls the "get_chunk" method on the "wallet" canister. -func (a Agent) GetChunk(arg0 struct { - Key Key `ic:"key" json:"key"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Index idl.Nat `ic:"index" json:"index"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` -}) (*struct { - Content []byte `ic:"content" json:"content"` -}, error) { - var r0 struct { - Content []byte `ic:"content" json:"content"` - } - if err := a.a.Query( +// RemoveController calls the "remove_controller" method on the "wallet" canister. +func (a Agent) RemoveController(arg0 principal.Principal) (*WalletResult, error) { + var r0 WalletResult + if err := a.a.Call( a.canisterId, - "get_chunk", + "remove_controller", []any{arg0}, []any{&r0}, ); err != nil { @@ -295,11 +295,11 @@ func (a Agent) GetChunk(arg0 struct { return &r0, nil } -// GrantPermission calls the "grant_permission" method on the "wallet" canister. -func (a Agent) GrantPermission(arg0 GrantPermission) error { +// SetName calls the "set_name" method on the "wallet" canister. +func (a Agent) SetName(arg0 string) error { if err := a.a.Call( a.canisterId, - "grant_permission", + "set_name", []any{arg0}, []any{}, ); err != nil { @@ -308,13 +308,13 @@ func (a Agent) GrantPermission(arg0 GrantPermission) error { return nil } -// HttpRequest calls the "http_request" method on the "wallet" canister. -func (a Agent) HttpRequest(request HttpRequest) (*HttpResponse, error) { - var r0 HttpResponse - if err := a.a.Query( +// SetShortName calls the "set_short_name" method on the "wallet" canister. +func (a Agent) SetShortName(arg0 principal.Principal, arg1 *string) (**ManagedCanisterInfo, error) { + var r0 *ManagedCanisterInfo + if err := a.a.Call( a.canisterId, - "http_request", - []any{request}, + "set_short_name", + []any{arg0, arg1}, []any{&r0}, ); err != nil { return nil, err @@ -322,13 +322,13 @@ func (a Agent) HttpRequest(request HttpRequest) (*HttpResponse, error) { return &r0, nil } -// HttpRequestStreamingCallback calls the "http_request_streaming_callback" method on the "wallet" canister. -func (a Agent) HttpRequestStreamingCallback(token StreamingCallbackToken) (**StreamingCallbackHttpResponse, error) { - var r0 *StreamingCallbackHttpResponse +// WalletApiVersion calls the "wallet_api_version" method on the "wallet" canister. +func (a Agent) WalletApiVersion() (*string, error) { + var r0 string if err := a.a.Query( a.canisterId, - "http_request_streaming_callback", - []any{token}, + "wallet_api_version", + []any{}, []any{&r0}, ); err != nil { return nil, err @@ -336,32 +336,17 @@ func (a Agent) HttpRequestStreamingCallback(token StreamingCallbackToken) (**Str return &r0, nil } -// List calls the "list" method on the "wallet" canister. -func (a Agent) List(arg0 struct { -}) (*[]struct { - Key Key `ic:"key" json:"key"` - ContentType string `ic:"content_type" json:"content_type"` - Encodings []struct { - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - Length idl.Nat `ic:"length" json:"length"` - Modified Time `ic:"modified" json:"modified"` - } `ic:"encodings" json:"encodings"` +// WalletBalance calls the "wallet_balance" method on the "wallet" canister. +func (a Agent) WalletBalance() (*struct { + Amount uint64 `ic:"amount" json:"amount"` }, error) { - var r0 []struct { - Key Key `ic:"key" json:"key"` - ContentType string `ic:"content_type" json:"content_type"` - Encodings []struct { - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - Length idl.Nat `ic:"length" json:"length"` - Modified Time `ic:"modified" json:"modified"` - } `ic:"encodings" json:"encodings"` + var r0 struct { + Amount uint64 `ic:"amount" json:"amount"` } if err := a.a.Query( a.canisterId, - "list", - []any{arg0}, + "wallet_balance", + []any{}, []any{&r0}, ); err != nil { return nil, err @@ -369,12 +354,16 @@ func (a Agent) List(arg0 struct { return &r0, nil } -// ListAuthorized calls the "list_authorized" method on the "wallet" canister. -func (a Agent) ListAuthorized() (*[]principal.Principal, error) { - var r0 []principal.Principal +// WalletBalance128 calls the "wallet_balance128" method on the "wallet" canister. +func (a Agent) WalletBalance128() (*struct { + Amount idl.Nat `ic:"amount" json:"amount"` +}, error) { + var r0 struct { + Amount idl.Nat `ic:"amount" json:"amount"` + } if err := a.a.Query( a.canisterId, - "list_authorized", + "wallet_balance128", []any{}, []any{&r0}, ); err != nil { @@ -383,12 +372,17 @@ func (a Agent) ListAuthorized() (*[]principal.Principal, error) { return &r0, nil } -// ListPermitted calls the "list_permitted" method on the "wallet" canister. -func (a Agent) ListPermitted(arg0 ListPermitted) (*[]principal.Principal, error) { - var r0 []principal.Principal - if err := a.a.Query( +// WalletCall calls the "wallet_call" method on the "wallet" canister. +func (a Agent) WalletCall(arg0 struct { + Canister principal.Principal `ic:"canister" json:"canister"` + MethodName string `ic:"method_name" json:"method_name"` + Args []byte `ic:"args" json:"args"` + Cycles uint64 `ic:"cycles" json:"cycles"` +}) (*WalletResultCall, error) { + var r0 WalletResultCall + if err := a.a.Call( a.canisterId, - "list_permitted", + "wallet_call", []any{arg0}, []any{&r0}, ); err != nil { @@ -397,95 +391,86 @@ func (a Agent) ListPermitted(arg0 ListPermitted) (*[]principal.Principal, error) return &r0, nil } -// ProposeCommitBatch calls the "propose_commit_batch" method on the "wallet" canister. -func (a Agent) ProposeCommitBatch(arg0 CommitBatchArguments) error { +// WalletCall128 calls the "wallet_call128" method on the "wallet" canister. +func (a Agent) WalletCall128(arg0 struct { + Canister principal.Principal `ic:"canister" json:"canister"` + MethodName string `ic:"method_name" json:"method_name"` + Args []byte `ic:"args" json:"args"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` +}) (*WalletResultCall, error) { + var r0 WalletResultCall if err := a.a.Call( a.canisterId, - "propose_commit_batch", + "wallet_call128", []any{arg0}, - []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// RevokePermission calls the "revoke_permission" method on the "wallet" canister. -func (a Agent) RevokePermission(arg0 RevokePermission) error { +// WalletCreateCanister calls the "wallet_create_canister" method on the "wallet" canister. +func (a Agent) WalletCreateCanister(arg0 CreateCanisterArgs) (*WalletResultCreate, error) { + var r0 WalletResultCreate if err := a.a.Call( a.canisterId, - "revoke_permission", + "wallet_create_canister", []any{arg0}, - []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// SetAssetContent calls the "set_asset_content" method on the "wallet" canister. -func (a Agent) SetAssetContent(arg0 SetAssetContentArguments) error { +// WalletCreateCanister128 calls the "wallet_create_canister128" method on the "wallet" canister. +func (a Agent) WalletCreateCanister128(arg0 CreateCanisterArgs128) (*WalletResultCreate, error) { + var r0 WalletResultCreate if err := a.a.Call( a.canisterId, - "set_asset_content", + "wallet_create_canister128", []any{arg0}, - []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// SetAssetProperties calls the "set_asset_properties" method on the "wallet" canister. -func (a Agent) SetAssetProperties(arg0 SetAssetPropertiesArguments) error { +// WalletCreateWallet calls the "wallet_create_wallet" method on the "wallet" canister. +func (a Agent) WalletCreateWallet(arg0 CreateCanisterArgs) (*WalletResultCreate, error) { + var r0 WalletResultCreate if err := a.a.Call( a.canisterId, - "set_asset_properties", + "wallet_create_wallet", []any{arg0}, - []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// Store calls the "store" method on the "wallet" canister. -func (a Agent) Store(arg0 struct { - Key Key `ic:"key" json:"key"` - ContentType string `ic:"content_type" json:"content_type"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Content []byte `ic:"content" json:"content"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` -}) error { +// WalletCreateWallet128 calls the "wallet_create_wallet128" method on the "wallet" canister. +func (a Agent) WalletCreateWallet128(arg0 CreateCanisterArgs128) (*WalletResultCreate, error) { + var r0 WalletResultCreate if err := a.a.Call( a.canisterId, - "store", + "wallet_create_wallet128", []any{arg0}, - []any{}, - ); err != nil { - return err - } - return nil -} - -// TakeOwnership calls the "take_ownership" method on the "wallet" canister. -func (a Agent) TakeOwnership() error { - if err := a.a.Call( - a.canisterId, - "take_ownership", - []any{}, - []any{}, + []any{&r0}, ); err != nil { - return err + return nil, err } - return nil + return &r0, nil } -// UnsetAssetContent calls the "unset_asset_content" method on the "wallet" canister. -func (a Agent) UnsetAssetContent(arg0 UnsetAssetContentArguments) error { +// WalletReceive calls the "wallet_receive" method on the "wallet" canister. +func (a Agent) WalletReceive(arg0 *ReceiveOptions) error { if err := a.a.Call( a.canisterId, - "unset_asset_content", + "wallet_receive", []any{arg0}, []any{}, ); err != nil { @@ -494,12 +479,15 @@ func (a Agent) UnsetAssetContent(arg0 UnsetAssetContentArguments) error { return nil } -// ValidateCommitProposedBatch calls the "validate_commit_proposed_batch" method on the "wallet" canister. -func (a Agent) ValidateCommitProposedBatch(arg0 CommitProposedBatchArguments) (*ValidationResult, error) { - var r0 ValidationResult +// WalletSend calls the "wallet_send" method on the "wallet" canister. +func (a Agent) WalletSend(arg0 struct { + Canister principal.Principal `ic:"canister" json:"canister"` + Amount uint64 `ic:"amount" json:"amount"` +}) (*WalletResult, error) { + var r0 WalletResult if err := a.a.Call( a.canisterId, - "validate_commit_proposed_batch", + "wallet_send", []any{arg0}, []any{&r0}, ); err != nil { @@ -508,12 +496,15 @@ func (a Agent) ValidateCommitProposedBatch(arg0 CommitProposedBatchArguments) (* return &r0, nil } -// ValidateGrantPermission calls the "validate_grant_permission" method on the "wallet" canister. -func (a Agent) ValidateGrantPermission(arg0 GrantPermission) (*ValidationResult, error) { - var r0 ValidationResult +// WalletSend128 calls the "wallet_send128" method on the "wallet" canister. +func (a Agent) WalletSend128(arg0 struct { + Canister principal.Principal `ic:"canister" json:"canister"` + Amount idl.Nat `ic:"amount" json:"amount"` +}) (*WalletResult, error) { + var r0 WalletResult if err := a.a.Call( a.canisterId, - "validate_grant_permission", + "wallet_send128", []any{arg0}, []any{&r0}, ); err != nil { @@ -522,85 +513,115 @@ func (a Agent) ValidateGrantPermission(arg0 GrantPermission) (*ValidationResult, return &r0, nil } -// ValidateRevokePermission calls the "validate_revoke_permission" method on the "wallet" canister. -func (a Agent) ValidateRevokePermission(arg0 RevokePermission) (*ValidationResult, error) { - var r0 ValidationResult +// WalletStoreWalletWasm calls the "wallet_store_wallet_wasm" method on the "wallet" canister. +func (a Agent) WalletStoreWalletWasm(arg0 struct { + WasmModule []byte `ic:"wasm_module" json:"wasm_module"` +}) error { if err := a.a.Call( a.canisterId, - "validate_revoke_permission", + "wallet_store_wallet_wasm", []any{arg0}, - []any{&r0}, - ); err != nil { - return nil, err - } - return &r0, nil -} - -// ValidateTakeOwnership calls the "validate_take_ownership" method on the "wallet" canister. -func (a Agent) ValidateTakeOwnership() (*ValidationResult, error) { - var r0 ValidationResult - if err := a.a.Call( - a.canisterId, - "validate_take_ownership", []any{}, - []any{&r0}, ); err != nil { - return nil, err + return err } - return &r0, nil -} - -type BatchId = idl.Nat - -type BatchOperationKind struct { - CreateAsset *CreateAssetArguments `ic:"CreateAsset,variant"` - SetAssetContent *SetAssetContentArguments `ic:"SetAssetContent,variant"` - SetAssetProperties *SetAssetPropertiesArguments `ic:"SetAssetProperties,variant"` - UnsetAssetContent *UnsetAssetContentArguments `ic:"UnsetAssetContent,variant"` - DeleteAsset *DeleteAssetArguments `ic:"DeleteAsset,variant"` - Clear *ClearArguments `ic:"Clear,variant"` -} - -type ChunkId = idl.Nat - -type ClearArguments struct { -} - -type CommitBatchArguments struct { - BatchId BatchId `ic:"batch_id" json:"batch_id"` - Operations []BatchOperationKind `ic:"operations" json:"operations"` -} - -type CommitProposedBatchArguments struct { - BatchId BatchId `ic:"batch_id" json:"batch_id"` - Evidence []byte `ic:"evidence" json:"evidence"` -} - -type ComputeEvidenceArguments struct { - BatchId BatchId `ic:"batch_id" json:"batch_id"` - MaxIterations *uint16 `ic:"max_iterations,omitempty" json:"max_iterations,omitempty"` -} - -type CreateAssetArguments struct { - Key Key `ic:"key" json:"key"` - ContentType string `ic:"content_type" json:"content_type"` - MaxAge *uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` - Headers *[]HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` - EnableAliasing *bool `ic:"enable_aliasing,omitempty" json:"enable_aliasing,omitempty"` - AllowRawAccess *bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` -} - -type DeleteAssetArguments struct { - Key Key `ic:"key" json:"key"` -} - -type DeleteBatchArguments struct { - BatchId BatchId `ic:"batch_id" json:"batch_id"` + return nil } -type GrantPermission struct { - ToPrincipal principal.Principal `ic:"to_principal" json:"to_principal"` - Permission Permission `ic:"permission" json:"permission"` +type CanisterSettings struct { + Controller *principal.Principal `ic:"controller,omitempty" json:"controller,omitempty"` + Controllers *[]principal.Principal `ic:"controllers,omitempty" json:"controllers,omitempty"` + ComputeAllocation *idl.Nat `ic:"compute_allocation,omitempty" json:"compute_allocation,omitempty"` + MemoryAllocation *idl.Nat `ic:"memory_allocation,omitempty" json:"memory_allocation,omitempty"` + FreezingThreshold *idl.Nat `ic:"freezing_threshold,omitempty" json:"freezing_threshold,omitempty"` +} + +type CreateCanisterArgs struct { + Cycles uint64 `ic:"cycles" json:"cycles"` + Settings CanisterSettings `ic:"settings" json:"settings"` +} + +type CreateCanisterArgs128 struct { + Cycles idl.Nat `ic:"cycles" json:"cycles"` + Settings CanisterSettings `ic:"settings" json:"settings"` +} + +type Event struct { + Id uint32 `ic:"id" json:"id"` + Timestamp uint64 `ic:"timestamp" json:"timestamp"` + Kind EventKind `ic:"kind" json:"kind"` +} + +type Event128 struct { + Id uint32 `ic:"id" json:"id"` + Timestamp uint64 `ic:"timestamp" json:"timestamp"` + Kind EventKind128 `ic:"kind" json:"kind"` +} + +type EventKind struct { + CyclesSent *struct { + To principal.Principal `ic:"to" json:"to"` + Amount uint64 `ic:"amount" json:"amount"` + Refund uint64 `ic:"refund" json:"refund"` + } `ic:"CyclesSent,variant"` + CyclesReceived *struct { + From principal.Principal `ic:"from" json:"from"` + Amount uint64 `ic:"amount" json:"amount"` + Memo *string `ic:"memo,omitempty" json:"memo,omitempty"` + } `ic:"CyclesReceived,variant"` + AddressAdded *struct { + Id principal.Principal `ic:"id" json:"id"` + Name *string `ic:"name,omitempty" json:"name,omitempty"` + Role Role `ic:"role" json:"role"` + } `ic:"AddressAdded,variant"` + AddressRemoved *struct { + Id principal.Principal `ic:"id" json:"id"` + } `ic:"AddressRemoved,variant"` + CanisterCreated *struct { + Canister principal.Principal `ic:"canister" json:"canister"` + Cycles uint64 `ic:"cycles" json:"cycles"` + } `ic:"CanisterCreated,variant"` + CanisterCalled *struct { + Canister principal.Principal `ic:"canister" json:"canister"` + MethodName string `ic:"method_name" json:"method_name"` + Cycles uint64 `ic:"cycles" json:"cycles"` + } `ic:"CanisterCalled,variant"` + WalletDeployed *struct { + Canister principal.Principal `ic:"canister" json:"canister"` + } `ic:"WalletDeployed,variant"` +} + +type EventKind128 struct { + CyclesSent *struct { + To principal.Principal `ic:"to" json:"to"` + Amount idl.Nat `ic:"amount" json:"amount"` + Refund idl.Nat `ic:"refund" json:"refund"` + } `ic:"CyclesSent,variant"` + CyclesReceived *struct { + From principal.Principal `ic:"from" json:"from"` + Amount idl.Nat `ic:"amount" json:"amount"` + Memo *string `ic:"memo,omitempty" json:"memo,omitempty"` + } `ic:"CyclesReceived,variant"` + AddressAdded *struct { + Id principal.Principal `ic:"id" json:"id"` + Name *string `ic:"name,omitempty" json:"name,omitempty"` + Role Role `ic:"role" json:"role"` + } `ic:"AddressAdded,variant"` + AddressRemoved *struct { + Id principal.Principal `ic:"id" json:"id"` + } `ic:"AddressRemoved,variant"` + CanisterCreated *struct { + Canister principal.Principal `ic:"canister" json:"canister"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + } `ic:"CanisterCreated,variant"` + CanisterCalled *struct { + Canister principal.Principal `ic:"canister" json:"canister"` + MethodName string `ic:"method_name" json:"method_name"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + } `ic:"CanisterCalled,variant"` + WalletDeployed *struct { + Canister principal.Principal `ic:"canister" json:"canister"` + } `ic:"WalletDeployed,variant"` } type HeaderField struct { @@ -609,11 +630,10 @@ type HeaderField struct { } type HttpRequest struct { - Method string `ic:"method" json:"method"` - Url string `ic:"url" json:"url"` - Headers []HeaderField `ic:"headers" json:"headers"` - Body []byte `ic:"body" json:"body"` - CertificateVersion *uint16 `ic:"certificate_version,omitempty" json:"certificate_version,omitempty"` + Method string `ic:"method" json:"method"` + Url string `ic:"url" json:"url"` + Headers []HeaderField `ic:"headers" json:"headers"` + Body []byte `ic:"body" json:"body"` } type HttpResponse struct { @@ -623,66 +643,99 @@ type HttpResponse struct { StreamingStrategy *StreamingStrategy `ic:"streaming_strategy,omitempty" json:"streaming_strategy,omitempty"` } -type Key = string +type Kind struct { + Unknown *idl.Null `ic:"Unknown,variant"` + User *idl.Null `ic:"User,variant"` + Canister *idl.Null `ic:"Canister,variant"` +} -type ListPermitted struct { - Permission Permission `ic:"permission" json:"permission"` +type ManagedCanisterEvent struct { + Id uint32 `ic:"id" json:"id"` + Timestamp uint64 `ic:"timestamp" json:"timestamp"` + Kind ManagedCanisterEventKind `ic:"kind" json:"kind"` } -type Permission struct { - Commit *idl.Null `ic:"Commit,variant"` - ManagePermissions *idl.Null `ic:"ManagePermissions,variant"` - Prepare *idl.Null `ic:"Prepare,variant"` +type ManagedCanisterEvent128 struct { + Id uint32 `ic:"id" json:"id"` + Timestamp uint64 `ic:"timestamp" json:"timestamp"` + Kind ManagedCanisterEventKind128 `ic:"kind" json:"kind"` } -type RevokePermission struct { - OfPrincipal principal.Principal `ic:"of_principal" json:"of_principal"` - Permission Permission `ic:"permission" json:"permission"` +type ManagedCanisterEventKind struct { + CyclesSent *struct { + Amount uint64 `ic:"amount" json:"amount"` + Refund uint64 `ic:"refund" json:"refund"` + } `ic:"CyclesSent,variant"` + Called *struct { + MethodName string `ic:"method_name" json:"method_name"` + Cycles uint64 `ic:"cycles" json:"cycles"` + } `ic:"Called,variant"` + Created *struct { + Cycles uint64 `ic:"cycles" json:"cycles"` + } `ic:"Created,variant"` } -type SetAssetContentArguments struct { - Key Key `ic:"key" json:"key"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - ChunkIds []ChunkId `ic:"chunk_ids" json:"chunk_ids"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` +type ManagedCanisterEventKind128 struct { + CyclesSent *struct { + Amount idl.Nat `ic:"amount" json:"amount"` + Refund idl.Nat `ic:"refund" json:"refund"` + } `ic:"CyclesSent,variant"` + Called *struct { + MethodName string `ic:"method_name" json:"method_name"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + } `ic:"Called,variant"` + Created *struct { + Cycles idl.Nat `ic:"cycles" json:"cycles"` + } `ic:"Created,variant"` } -type SetAssetPropertiesArguments struct { - Key Key `ic:"key" json:"key"` - MaxAge **uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` - Headers **[]HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` - AllowRawAccess **bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` - IsAliased **bool `ic:"is_aliased,omitempty" json:"is_aliased,omitempty"` +type ManagedCanisterInfo struct { + Id principal.Principal `ic:"id" json:"id"` + Name *string `ic:"name,omitempty" json:"name,omitempty"` + CreatedAt uint64 `ic:"created_at" json:"created_at"` } -type StreamingCallbackHttpResponse struct { - Body []byte `ic:"body" json:"body"` - Token *StreamingCallbackToken `ic:"token,omitempty" json:"token,omitempty"` +type ReceiveOptions struct { + Memo *string `ic:"memo,omitempty" json:"memo,omitempty"` } -type StreamingCallbackToken struct { - Key Key `ic:"key" json:"key"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Index idl.Nat `ic:"index" json:"index"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` +type Role struct { + Contact *idl.Null `ic:"Contact,variant"` + Custodian *idl.Null `ic:"Custodian,variant"` + Controller *idl.Null `ic:"Controller,variant"` +} + +type StreamingCallbackHttpResponse struct { + Body []byte `ic:"body" json:"body"` + Token *Token `ic:"token,omitempty" json:"token,omitempty"` } type StreamingStrategy struct { Callback *struct { Callback struct { /* NOT SUPPORTED */ } `ic:"callback" json:"callback"` - Token StreamingCallbackToken `ic:"token" json:"token"` + Token Token `ic:"token" json:"token"` } `ic:"Callback,variant"` } -type Time = idl.Int +type Token struct { +} + +type WalletResult struct { + Ok *idl.Null `ic:"Ok,variant"` + Err *string `ic:"Err,variant"` +} -type UnsetAssetContentArguments struct { - Key Key `ic:"key" json:"key"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` +type WalletResultCall struct { + Ok *struct { + Return []byte `ic:"return" json:"return"` + } `ic:"Ok,variant"` + Err *string `ic:"Err,variant"` } -type ValidationResult struct { - Ok *string `ic:"Ok,variant"` +type WalletResultCreate struct { + Ok *struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + } `ic:"Ok,variant"` Err *string `ic:"Err,variant"` } diff --git a/ic/wallet/agent_test.go b/ic/wallet/agent_test.go index 127af7f..017ce0c 100755 --- a/ic/wallet/agent_test.go +++ b/ic/wallet/agent_test.go @@ -13,14 +13,14 @@ import ( "github.com/aviate-labs/agent-go/ic/wallet" ) -// Test_ApiVersion tests the "api_version" method on the "wallet" canister. -func Test_ApiVersion(t *testing.T) { +// Test_AddAddress tests the "add_address" method on the "wallet" canister. +func Test_AddAddress(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "api_version", - Arguments: []any{}, + Name: "add_address", + Arguments: []any{new(wallet.AddressEntry)}, Handler: func(request mock.Request) ([]any, error) { - return []any{*new(uint16)}, nil + return []any{}, nil }, }, }) @@ -28,17 +28,27 @@ func Test_ApiVersion(t *testing.T) { t.Fatal(err) } - if _, err := a.ApiVersion(); err != nil { + var a0 = wallet.AddressEntry{ + *new(principal.Principal), + *new(*string), + wallet.Kind{ + Unknown: new(idl.Null), + }, + wallet.Role{ + Contact: new(idl.Null), + }, + } + if err := a.AddAddress(a0); err != nil { t.Fatal(err) } } -// Test_Authorize tests the "authorize" method on the "wallet" canister. -func Test_Authorize(t *testing.T) { +// Test_AddController tests the "add_controller" method on the "wallet" canister. +func Test_AddController(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "authorize", + Name: "add_controller", Arguments: []any{new(principal.Principal)}, Handler: func(request mock.Request) ([]any, error) { return []any{}, nil @@ -50,27 +60,20 @@ func Test_Authorize(t *testing.T) { } var a0 = *new(principal.Principal) - if err := a.Authorize(a0); err != nil { + if err := a.AddController(a0); err != nil { t.Fatal(err) } } -// Test_CertifiedTree tests the "certified_tree" method on the "wallet" canister. -func Test_CertifiedTree(t *testing.T) { +// Test_Authorize tests the "authorize" method on the "wallet" canister. +func Test_Authorize(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "certified_tree", - Arguments: []any{new(struct { - })}, + Name: "authorize", + Arguments: []any{new(principal.Principal)}, Handler: func(request mock.Request) ([]any, error) { - return []any{struct { - Certificate []byte `ic:"certificate" json:"certificate"` - Tree []byte `ic:"tree" json:"tree"` - }{ - *new([]byte), - *new([]byte), - }}, nil + return []any{}, nil }, }, }) @@ -78,22 +81,23 @@ func Test_CertifiedTree(t *testing.T) { t.Fatal(err) } - var a0 = struct { - }{} - if _, err := a.CertifiedTree(a0); err != nil { + var a0 = *new(principal.Principal) + if err := a.Authorize(a0); err != nil { t.Fatal(err) } } -// Test_Clear tests the "clear" method on the "wallet" canister. -func Test_Clear(t *testing.T) { +// Test_Deauthorize tests the "deauthorize" method on the "wallet" canister. +func Test_Deauthorize(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "clear", - Arguments: []any{new(wallet.ClearArguments)}, + Name: "deauthorize", + Arguments: []any{new(principal.Principal)}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{wallet.WalletResult{ + Ok: new(idl.Null), + }}, nil }, }, }) @@ -101,21 +105,32 @@ func Test_Clear(t *testing.T) { t.Fatal(err) } - var a0 = wallet.ClearArguments{} - if err := a.Clear(a0); err != nil { + var a0 = *new(principal.Principal) + if _, err := a.Deauthorize(a0); err != nil { t.Fatal(err) } } -// Test_CommitBatch tests the "commit_batch" method on the "wallet" canister. -func Test_CommitBatch(t *testing.T) { +// Test_GetChart tests the "get_chart" method on the "wallet" canister. +func Test_GetChart(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "commit_batch", - Arguments: []any{new(wallet.CommitBatchArguments)}, + Name: "get_chart", + Arguments: []any{new(*struct { + Count *uint32 `ic:"count,omitempty" json:"count,omitempty"` + Precision *uint64 `ic:"precision,omitempty" json:"precision,omitempty"` + })}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{[]struct { + Field0 uint64 `ic:"0" json:"0"` + Field1 uint64 `ic:"1" json:"1"` + }{ + + { + *new(uint64), + *new(uint64), + }}}, nil }, }, }) @@ -123,33 +138,24 @@ func Test_CommitBatch(t *testing.T) { t.Fatal(err) } - var a0 = wallet.CommitBatchArguments{ - idl.NewNat(uint(0)), - []wallet.BatchOperationKind{{ - CreateAsset: idl.Ptr(wallet.CreateAssetArguments{ - *new(string), - *new(string), - *new(*uint64), - *new(*[]wallet.HeaderField), - *new(*bool), - *new(*bool), - }), - }}, - } - if err := a.CommitBatch(a0); err != nil { + var a0 = *new(*struct { + Count *uint32 `ic:"count,omitempty" json:"count,omitempty"` + Precision *uint64 `ic:"precision,omitempty" json:"precision,omitempty"` + }) + if _, err := a.GetChart(a0); err != nil { t.Fatal(err) } } -// Test_CommitProposedBatch tests the "commit_proposed_batch" method on the "wallet" canister. -func Test_CommitProposedBatch(t *testing.T) { +// Test_GetControllers tests the "get_controllers" method on the "wallet" canister. +func Test_GetControllers(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "commit_proposed_batch", - Arguments: []any{new(wallet.CommitProposedBatchArguments)}, + Name: "get_controllers", + Arguments: []any{}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{[]principal.Principal{*new(principal.Principal)}}, nil }, }, }) @@ -157,24 +163,20 @@ func Test_CommitProposedBatch(t *testing.T) { t.Fatal(err) } - var a0 = wallet.CommitProposedBatchArguments{ - idl.NewNat(uint(0)), - *new([]byte), - } - if err := a.CommitProposedBatch(a0); err != nil { + if _, err := a.GetControllers(); err != nil { t.Fatal(err) } } -// Test_ComputeEvidence tests the "compute_evidence" method on the "wallet" canister. -func Test_ComputeEvidence(t *testing.T) { +// Test_GetCustodians tests the "get_custodians" method on the "wallet" canister. +func Test_GetCustodians(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "compute_evidence", - Arguments: []any{new(wallet.ComputeEvidenceArguments)}, + Name: "get_custodians", + Arguments: []any{}, Handler: func(request mock.Request) ([]any, error) { - return []any{*new(*[]byte)}, nil + return []any{[]principal.Principal{*new(principal.Principal)}}, nil }, }, }) @@ -182,24 +184,37 @@ func Test_ComputeEvidence(t *testing.T) { t.Fatal(err) } - var a0 = wallet.ComputeEvidenceArguments{ - idl.NewNat(uint(0)), - *new(*uint16), - } - if _, err := a.ComputeEvidence(a0); err != nil { + if _, err := a.GetCustodians(); err != nil { t.Fatal(err) } } -// Test_CreateAsset tests the "create_asset" method on the "wallet" canister. -func Test_CreateAsset(t *testing.T) { +// Test_GetEvents tests the "get_events" method on the "wallet" canister. +func Test_GetEvents(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "create_asset", - Arguments: []any{new(wallet.CreateAssetArguments)}, + Name: "get_events", + Arguments: []any{new(*struct { + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` + })}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{[]wallet.Event{{ + *new(uint32), + *new(uint64), + wallet.EventKind{ + CyclesSent: idl.Ptr(struct { + To principal.Principal `ic:"to" json:"to"` + Amount uint64 `ic:"amount" json:"amount"` + Refund uint64 `ic:"refund" json:"refund"` + }{ + *new(principal.Principal), + *new(uint64), + *new(uint64), + }), + }, + }}}, nil }, }, }) @@ -207,33 +222,41 @@ func Test_CreateAsset(t *testing.T) { t.Fatal(err) } - var a0 = wallet.CreateAssetArguments{ - *new(string), - *new(string), - *new(*uint64), - *new(*[]wallet.HeaderField), - *new(*bool), - *new(*bool), - } - if err := a.CreateAsset(a0); err != nil { + var a0 = *new(*struct { + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` + }) + if _, err := a.GetEvents(a0); err != nil { t.Fatal(err) } } -// Test_CreateBatch tests the "create_batch" method on the "wallet" canister. -func Test_CreateBatch(t *testing.T) { +// Test_GetEvents128 tests the "get_events128" method on the "wallet" canister. +func Test_GetEvents128(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "create_batch", - Arguments: []any{new(struct { + Name: "get_events128", + Arguments: []any{new(*struct { + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` })}, Handler: func(request mock.Request) ([]any, error) { - return []any{struct { - BatchId wallet.BatchId `ic:"batch_id" json:"batch_id"` - }{ - idl.NewNat(uint(0)), - }}, nil + return []any{[]wallet.Event128{{ + *new(uint32), + *new(uint64), + wallet.EventKind128{ + CyclesSent: idl.Ptr(struct { + To principal.Principal `ic:"to" json:"to"` + Amount idl.Nat `ic:"amount" json:"amount"` + Refund idl.Nat `ic:"refund" json:"refund"` + }{ + *new(principal.Principal), + idl.NewNat(uint(0)), + idl.NewNat(uint(0)), + }), + }, + }}}, nil }, }, }) @@ -241,29 +264,28 @@ func Test_CreateBatch(t *testing.T) { t.Fatal(err) } - var a0 = struct { - }{} - if _, err := a.CreateBatch(a0); err != nil { + var a0 = *new(*struct { + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` + }) + if _, err := a.GetEvents128(a0); err != nil { t.Fatal(err) } } -// Test_CreateChunk tests the "create_chunk" method on the "wallet" canister. -func Test_CreateChunk(t *testing.T) { +// Test_GetManagedCanisterEvents tests the "get_managed_canister_events" method on the "wallet" canister. +func Test_GetManagedCanisterEvents(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "create_chunk", + Name: "get_managed_canister_events", Arguments: []any{new(struct { - BatchId wallet.BatchId `ic:"batch_id" json:"batch_id"` - Content []byte `ic:"content" json:"content"` + Canister principal.Principal `ic:"canister" json:"canister"` + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` })}, Handler: func(request mock.Request) ([]any, error) { - return []any{struct { - ChunkId wallet.ChunkId `ic:"chunk_id" json:"chunk_id"` - }{ - idl.NewNat(uint(0)), - }}, nil + return []any{*new(*[]wallet.ManagedCanisterEvent)}, nil }, }, }) @@ -272,26 +294,32 @@ func Test_CreateChunk(t *testing.T) { } var a0 = struct { - BatchId wallet.BatchId `ic:"batch_id" json:"batch_id"` - Content []byte `ic:"content" json:"content"` + Canister principal.Principal `ic:"canister" json:"canister"` + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` }{ - idl.NewNat(uint(0)), - *new([]byte), + *new(principal.Principal), + *new(*uint32), + *new(*uint32), } - if _, err := a.CreateChunk(a0); err != nil { + if _, err := a.GetManagedCanisterEvents(a0); err != nil { t.Fatal(err) } } -// Test_Deauthorize tests the "deauthorize" method on the "wallet" canister. -func Test_Deauthorize(t *testing.T) { +// Test_GetManagedCanisterEvents128 tests the "get_managed_canister_events128" method on the "wallet" canister. +func Test_GetManagedCanisterEvents128(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "deauthorize", - Arguments: []any{new(principal.Principal)}, + Name: "get_managed_canister_events128", + Arguments: []any{new(struct { + Canister principal.Principal `ic:"canister" json:"canister"` + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` + })}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{*new(*[]wallet.ManagedCanisterEvent128)}, nil }, }, }) @@ -299,21 +327,37 @@ func Test_Deauthorize(t *testing.T) { t.Fatal(err) } - var a0 = *new(principal.Principal) - if err := a.Deauthorize(a0); err != nil { + var a0 = struct { + Canister principal.Principal `ic:"canister" json:"canister"` + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` + }{ + *new(principal.Principal), + *new(*uint32), + *new(*uint32), + } + if _, err := a.GetManagedCanisterEvents128(a0); err != nil { t.Fatal(err) } } -// Test_DeleteAsset tests the "delete_asset" method on the "wallet" canister. -func Test_DeleteAsset(t *testing.T) { +// Test_HttpRequest tests the "http_request" method on the "wallet" canister. +func Test_HttpRequest(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "delete_asset", - Arguments: []any{new(wallet.DeleteAssetArguments)}, + Name: "http_request", + Arguments: []any{new(wallet.HttpRequest)}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{wallet.HttpResponse{ + *new(uint16), + []wallet.HeaderField{{ + *new(string), + *new(string), + }}, + *new([]byte), + *new(*wallet.StreamingStrategy), + }}, nil }, }, }) @@ -321,23 +365,38 @@ func Test_DeleteAsset(t *testing.T) { t.Fatal(err) } - var a0 = wallet.DeleteAssetArguments{ + var a0 = wallet.HttpRequest{ *new(string), + *new(string), + []wallet.HeaderField{{ + *new(string), + *new(string), + }}, + *new([]byte), } - if err := a.DeleteAsset(a0); err != nil { + if _, err := a.HttpRequest(a0); err != nil { t.Fatal(err) } } -// Test_DeleteBatch tests the "delete_batch" method on the "wallet" canister. -func Test_DeleteBatch(t *testing.T) { +// Test_ListAddresses tests the "list_addresses" method on the "wallet" canister. +func Test_ListAddresses(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "delete_batch", - Arguments: []any{new(wallet.DeleteBatchArguments)}, + Name: "list_addresses", + Arguments: []any{}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{[]wallet.AddressEntry{{ + *new(principal.Principal), + *new(*string), + wallet.Kind{ + Unknown: new(idl.Null), + }, + wallet.Role{ + Contact: new(idl.Null), + }, + }}}, nil }, }, }) @@ -345,38 +404,27 @@ func Test_DeleteBatch(t *testing.T) { t.Fatal(err) } - var a0 = wallet.DeleteBatchArguments{ - idl.NewNat(uint(0)), - } - if err := a.DeleteBatch(a0); err != nil { + if _, err := a.ListAddresses(); err != nil { t.Fatal(err) } } -// Test_Get tests the "get" method on the "wallet" canister. -func Test_Get(t *testing.T) { +// Test_ListManagedCanisters tests the "list_managed_canisters" method on the "wallet" canister. +func Test_ListManagedCanisters(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "get", + Name: "list_managed_canisters", Arguments: []any{new(struct { - Key wallet.Key `ic:"key" json:"key"` - AcceptEncodings []string `ic:"accept_encodings" json:"accept_encodings"` + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` })}, Handler: func(request mock.Request) ([]any, error) { - return []any{struct { - Content []byte `ic:"content" json:"content"` - ContentType string `ic:"content_type" json:"content_type"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - TotalLength idl.Nat `ic:"total_length" json:"total_length"` - }{ - *new([]byte), - *new(string), - *new(string), - *new(*[]byte), - idl.NewNat(uint(0)), - }}, nil + return []any{[]wallet.ManagedCanisterInfo{{ + *new(principal.Principal), + *new(*string), + *new(uint64), + }}, *new(uint32)}, nil }, }, }) @@ -385,36 +433,26 @@ func Test_Get(t *testing.T) { } var a0 = struct { - Key wallet.Key `ic:"key" json:"key"` - AcceptEncodings []string `ic:"accept_encodings" json:"accept_encodings"` + From *uint32 `ic:"from,omitempty" json:"from,omitempty"` + To *uint32 `ic:"to,omitempty" json:"to,omitempty"` }{ - *new(string), - []string{*new(string)}, + *new(*uint32), + *new(*uint32), } - if _, err := a.Get(a0); err != nil { + if _, _, err := a.ListManagedCanisters(a0); err != nil { t.Fatal(err) } } -// Test_GetAssetProperties tests the "get_asset_properties" method on the "wallet" canister. -func Test_GetAssetProperties(t *testing.T) { +// Test_Name tests the "name" method on the "wallet" canister. +func Test_Name(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "get_asset_properties", - Arguments: []any{new(wallet.Key)}, + Name: "name", + Arguments: []any{}, Handler: func(request mock.Request) ([]any, error) { - return []any{struct { - MaxAge *uint64 `ic:"max_age,omitempty" json:"max_age,omitempty"` - Headers *[]wallet.HeaderField `ic:"headers,omitempty" json:"headers,omitempty"` - AllowRawAccess *bool `ic:"allow_raw_access,omitempty" json:"allow_raw_access,omitempty"` - IsAliased *bool `ic:"is_aliased,omitempty" json:"is_aliased,omitempty"` - }{ - *new(*uint64), - *new(*[]wallet.HeaderField), - *new(*bool), - *new(*bool), - }}, nil + return []any{*new(*string)}, nil }, }, }) @@ -422,29 +460,21 @@ func Test_GetAssetProperties(t *testing.T) { t.Fatal(err) } - var a0 = *new(string) - if _, err := a.GetAssetProperties(a0); err != nil { + if _, err := a.Name(); err != nil { t.Fatal(err) } } -// Test_GetChunk tests the "get_chunk" method on the "wallet" canister. -func Test_GetChunk(t *testing.T) { +// Test_RemoveAddress tests the "remove_address" method on the "wallet" canister. +func Test_RemoveAddress(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "get_chunk", - Arguments: []any{new(struct { - Key wallet.Key `ic:"key" json:"key"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Index idl.Nat `ic:"index" json:"index"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - })}, + Name: "remove_address", + Arguments: []any{new(principal.Principal)}, Handler: func(request mock.Request) ([]any, error) { - return []any{struct { - Content []byte `ic:"content" json:"content"` - }{ - *new([]byte), + return []any{wallet.WalletResult{ + Ok: new(idl.Null), }}, nil }, }, @@ -453,65 +483,22 @@ func Test_GetChunk(t *testing.T) { t.Fatal(err) } - var a0 = struct { - Key wallet.Key `ic:"key" json:"key"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Index idl.Nat `ic:"index" json:"index"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - }{ - *new(string), - *new(string), - idl.NewNat(uint(0)), - *new(*[]byte), - } - if _, err := a.GetChunk(a0); err != nil { - t.Fatal(err) - } - -} - -// Test_GrantPermission tests the "grant_permission" method on the "wallet" canister. -func Test_GrantPermission(t *testing.T) { - a, err := newAgent([]mock.Method{ - { - Name: "grant_permission", - Arguments: []any{new(wallet.GrantPermission)}, - Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil - }, - }, - }) - if err != nil { - t.Fatal(err) - } - - var a0 = wallet.GrantPermission{ - *new(principal.Principal), - wallet.Permission{ - Commit: new(idl.Null), - }, - } - if err := a.GrantPermission(a0); err != nil { + var a0 = *new(principal.Principal) + if _, err := a.RemoveAddress(a0); err != nil { t.Fatal(err) } } -// Test_HttpRequest tests the "http_request" method on the "wallet" canister. -func Test_HttpRequest(t *testing.T) { +// Test_RemoveController tests the "remove_controller" method on the "wallet" canister. +func Test_RemoveController(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "http_request", - Arguments: []any{new(wallet.HttpRequest)}, + Name: "remove_controller", + Arguments: []any{new(principal.Principal)}, Handler: func(request mock.Request) ([]any, error) { - return []any{wallet.HttpResponse{ - *new(uint16), - []wallet.HeaderField{{ - *new(string), - *new(string), - }}, - *new([]byte), - *new(*wallet.StreamingStrategy), + return []any{wallet.WalletResult{ + Ok: new(idl.Null), }}, nil }, }, @@ -520,30 +507,21 @@ func Test_HttpRequest(t *testing.T) { t.Fatal(err) } - var a0 = wallet.HttpRequest{ - *new(string), - *new(string), - []wallet.HeaderField{{ - *new(string), - *new(string), - }}, - *new([]byte), - *new(*uint16), - } - if _, err := a.HttpRequest(a0); err != nil { + var a0 = *new(principal.Principal) + if _, err := a.RemoveController(a0); err != nil { t.Fatal(err) } } -// Test_HttpRequestStreamingCallback tests the "http_request_streaming_callback" method on the "wallet" canister. -func Test_HttpRequestStreamingCallback(t *testing.T) { +// Test_SetName tests the "set_name" method on the "wallet" canister. +func Test_SetName(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "http_request_streaming_callback", - Arguments: []any{new(wallet.StreamingCallbackToken)}, + Name: "set_name", + Arguments: []any{new(string)}, Handler: func(request mock.Request) ([]any, error) { - return []any{*new(*wallet.StreamingCallbackHttpResponse)}, nil + return []any{}, nil }, }, }) @@ -551,54 +529,21 @@ func Test_HttpRequestStreamingCallback(t *testing.T) { t.Fatal(err) } - var a0 = wallet.StreamingCallbackToken{ - *new(string), - *new(string), - idl.NewNat(uint(0)), - *new(*[]byte), - } - if _, err := a.HttpRequestStreamingCallback(a0); err != nil { + var a0 = *new(string) + if err := a.SetName(a0); err != nil { t.Fatal(err) } } -// Test_List tests the "list" method on the "wallet" canister. -func Test_List(t *testing.T) { +// Test_SetShortName tests the "set_short_name" method on the "wallet" canister. +func Test_SetShortName(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "list", - Arguments: []any{new(struct { - })}, + Name: "set_short_name", + Arguments: []any{new(principal.Principal), new(*string)}, Handler: func(request mock.Request) ([]any, error) { - return []any{[]struct { - Key wallet.Key `ic:"key" json:"key"` - ContentType string `ic:"content_type" json:"content_type"` - Encodings []struct { - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - Length idl.Nat `ic:"length" json:"length"` - Modified wallet.Time `ic:"modified" json:"modified"` - } `ic:"encodings" json:"encodings"` - }{ - - { - *new(string), - *new(string), - []struct { - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - Length idl.Nat `ic:"length" json:"length"` - Modified wallet.Time `ic:"modified" json:"modified"` - }{ - - { - *new(string), - *new(*[]byte), - idl.NewNat(uint(0)), - idl.NewInt(0), - }}, - }}}, nil + return []any{*new(*wallet.ManagedCanisterInfo)}, nil }, }, }) @@ -606,22 +551,22 @@ func Test_List(t *testing.T) { t.Fatal(err) } - var a0 = struct { - }{} - if _, err := a.List(a0); err != nil { + var a0 = *new(principal.Principal) + var a1 = *new(*string) + if _, err := a.SetShortName(a0, a1); err != nil { t.Fatal(err) } } -// Test_ListAuthorized tests the "list_authorized" method on the "wallet" canister. -func Test_ListAuthorized(t *testing.T) { +// Test_WalletApiVersion tests the "wallet_api_version" method on the "wallet" canister. +func Test_WalletApiVersion(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "list_authorized", + Name: "wallet_api_version", Arguments: []any{}, Handler: func(request mock.Request) ([]any, error) { - return []any{[]principal.Principal{*new(principal.Principal)}}, nil + return []any{*new(string)}, nil }, }, }) @@ -629,20 +574,24 @@ func Test_ListAuthorized(t *testing.T) { t.Fatal(err) } - if _, err := a.ListAuthorized(); err != nil { + if _, err := a.WalletApiVersion(); err != nil { t.Fatal(err) } } -// Test_ListPermitted tests the "list_permitted" method on the "wallet" canister. -func Test_ListPermitted(t *testing.T) { +// Test_WalletBalance tests the "wallet_balance" method on the "wallet" canister. +func Test_WalletBalance(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "list_permitted", - Arguments: []any{new(wallet.ListPermitted)}, + Name: "wallet_balance", + Arguments: []any{}, Handler: func(request mock.Request) ([]any, error) { - return []any{[]principal.Principal{*new(principal.Principal)}}, nil + return []any{struct { + Amount uint64 `ic:"amount" json:"amount"` + }{ + *new(uint64), + }}, nil }, }, }) @@ -650,25 +599,24 @@ func Test_ListPermitted(t *testing.T) { t.Fatal(err) } - var a0 = wallet.ListPermitted{ - wallet.Permission{ - Commit: new(idl.Null), - }, - } - if _, err := a.ListPermitted(a0); err != nil { + if _, err := a.WalletBalance(); err != nil { t.Fatal(err) } } -// Test_ProposeCommitBatch tests the "propose_commit_batch" method on the "wallet" canister. -func Test_ProposeCommitBatch(t *testing.T) { +// Test_WalletBalance128 tests the "wallet_balance128" method on the "wallet" canister. +func Test_WalletBalance128(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "propose_commit_batch", - Arguments: []any{new(wallet.CommitBatchArguments)}, + Name: "wallet_balance128", + Arguments: []any{}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{struct { + Amount idl.Nat `ic:"amount" json:"amount"` + }{ + idl.NewNat(uint(0)), + }}, nil }, }, }) @@ -676,33 +624,31 @@ func Test_ProposeCommitBatch(t *testing.T) { t.Fatal(err) } - var a0 = wallet.CommitBatchArguments{ - idl.NewNat(uint(0)), - []wallet.BatchOperationKind{{ - CreateAsset: idl.Ptr(wallet.CreateAssetArguments{ - *new(string), - *new(string), - *new(*uint64), - *new(*[]wallet.HeaderField), - *new(*bool), - *new(*bool), - }), - }}, - } - if err := a.ProposeCommitBatch(a0); err != nil { + if _, err := a.WalletBalance128(); err != nil { t.Fatal(err) } } -// Test_RevokePermission tests the "revoke_permission" method on the "wallet" canister. -func Test_RevokePermission(t *testing.T) { +// Test_WalletCall tests the "wallet_call" method on the "wallet" canister. +func Test_WalletCall(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "revoke_permission", - Arguments: []any{new(wallet.RevokePermission)}, + Name: "wallet_call", + Arguments: []any{new(struct { + Canister principal.Principal `ic:"canister" json:"canister"` + MethodName string `ic:"method_name" json:"method_name"` + Args []byte `ic:"args" json:"args"` + Cycles uint64 `ic:"cycles" json:"cycles"` + })}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{wallet.WalletResultCall{ + Ok: idl.Ptr(struct { + Return []byte `ic:"return" json:"return"` + }{ + *new([]byte), + }), + }}, nil }, }, }) @@ -710,26 +656,42 @@ func Test_RevokePermission(t *testing.T) { t.Fatal(err) } - var a0 = wallet.RevokePermission{ + var a0 = struct { + Canister principal.Principal `ic:"canister" json:"canister"` + MethodName string `ic:"method_name" json:"method_name"` + Args []byte `ic:"args" json:"args"` + Cycles uint64 `ic:"cycles" json:"cycles"` + }{ *new(principal.Principal), - wallet.Permission{ - Commit: new(idl.Null), - }, + *new(string), + *new([]byte), + *new(uint64), } - if err := a.RevokePermission(a0); err != nil { + if _, err := a.WalletCall(a0); err != nil { t.Fatal(err) } } -// Test_SetAssetContent tests the "set_asset_content" method on the "wallet" canister. -func Test_SetAssetContent(t *testing.T) { +// Test_WalletCall128 tests the "wallet_call128" method on the "wallet" canister. +func Test_WalletCall128(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "set_asset_content", - Arguments: []any{new(wallet.SetAssetContentArguments)}, + Name: "wallet_call128", + Arguments: []any{new(struct { + Canister principal.Principal `ic:"canister" json:"canister"` + MethodName string `ic:"method_name" json:"method_name"` + Args []byte `ic:"args" json:"args"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + })}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{wallet.WalletResultCall{ + Ok: idl.Ptr(struct { + Return []byte `ic:"return" json:"return"` + }{ + *new([]byte), + }), + }}, nil }, }, }) @@ -737,26 +699,37 @@ func Test_SetAssetContent(t *testing.T) { t.Fatal(err) } - var a0 = wallet.SetAssetContentArguments{ - *new(string), + var a0 = struct { + Canister principal.Principal `ic:"canister" json:"canister"` + MethodName string `ic:"method_name" json:"method_name"` + Args []byte `ic:"args" json:"args"` + Cycles idl.Nat `ic:"cycles" json:"cycles"` + }{ + *new(principal.Principal), *new(string), - []wallet.ChunkId{idl.NewNat(uint(0))}, - *new(*[]byte), + *new([]byte), + idl.NewNat(uint(0)), } - if err := a.SetAssetContent(a0); err != nil { + if _, err := a.WalletCall128(a0); err != nil { t.Fatal(err) } } -// Test_SetAssetProperties tests the "set_asset_properties" method on the "wallet" canister. -func Test_SetAssetProperties(t *testing.T) { +// Test_WalletCreateCanister tests the "wallet_create_canister" method on the "wallet" canister. +func Test_WalletCreateCanister(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "set_asset_properties", - Arguments: []any{new(wallet.SetAssetPropertiesArguments)}, + Name: "wallet_create_canister", + Arguments: []any{new(wallet.CreateCanisterArgs)}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{wallet.WalletResultCreate{ + Ok: idl.Ptr(struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + }{ + *new(principal.Principal), + }), + }}, nil }, }, }) @@ -764,33 +737,36 @@ func Test_SetAssetProperties(t *testing.T) { t.Fatal(err) } - var a0 = wallet.SetAssetPropertiesArguments{ - *new(string), - *new(**uint64), - *new(**[]wallet.HeaderField), - *new(**bool), - *new(**bool), + var a0 = wallet.CreateCanisterArgs{ + *new(uint64), + wallet.CanisterSettings{ + *new(*principal.Principal), + *new(*[]principal.Principal), + *new(*idl.Nat), + *new(*idl.Nat), + *new(*idl.Nat), + }, } - if err := a.SetAssetProperties(a0); err != nil { + if _, err := a.WalletCreateCanister(a0); err != nil { t.Fatal(err) } } -// Test_Store tests the "store" method on the "wallet" canister. -func Test_Store(t *testing.T) { +// Test_WalletCreateCanister128 tests the "wallet_create_canister128" method on the "wallet" canister. +func Test_WalletCreateCanister128(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "store", - Arguments: []any{new(struct { - Key wallet.Key `ic:"key" json:"key"` - ContentType string `ic:"content_type" json:"content_type"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Content []byte `ic:"content" json:"content"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - })}, + Name: "wallet_create_canister128", + Arguments: []any{new(wallet.CreateCanisterArgs128)}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{wallet.WalletResultCreate{ + Ok: idl.Ptr(struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + }{ + *new(principal.Principal), + }), + }}, nil }, }, }) @@ -798,33 +774,36 @@ func Test_Store(t *testing.T) { t.Fatal(err) } - var a0 = struct { - Key wallet.Key `ic:"key" json:"key"` - ContentType string `ic:"content_type" json:"content_type"` - ContentEncoding string `ic:"content_encoding" json:"content_encoding"` - Content []byte `ic:"content" json:"content"` - Sha256 *[]byte `ic:"sha256,omitempty" json:"sha256,omitempty"` - }{ - *new(string), - *new(string), - *new(string), - *new([]byte), - *new(*[]byte), + var a0 = wallet.CreateCanisterArgs128{ + idl.NewNat(uint(0)), + wallet.CanisterSettings{ + *new(*principal.Principal), + *new(*[]principal.Principal), + *new(*idl.Nat), + *new(*idl.Nat), + *new(*idl.Nat), + }, } - if err := a.Store(a0); err != nil { + if _, err := a.WalletCreateCanister128(a0); err != nil { t.Fatal(err) } } -// Test_TakeOwnership tests the "take_ownership" method on the "wallet" canister. -func Test_TakeOwnership(t *testing.T) { +// Test_WalletCreateWallet tests the "wallet_create_wallet" method on the "wallet" canister. +func Test_WalletCreateWallet(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "take_ownership", - Arguments: []any{}, + Name: "wallet_create_wallet", + Arguments: []any{new(wallet.CreateCanisterArgs)}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{wallet.WalletResultCreate{ + Ok: idl.Ptr(struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + }{ + *new(principal.Principal), + }), + }}, nil }, }, }) @@ -832,20 +811,36 @@ func Test_TakeOwnership(t *testing.T) { t.Fatal(err) } - if err := a.TakeOwnership(); err != nil { + var a0 = wallet.CreateCanisterArgs{ + *new(uint64), + wallet.CanisterSettings{ + *new(*principal.Principal), + *new(*[]principal.Principal), + *new(*idl.Nat), + *new(*idl.Nat), + *new(*idl.Nat), + }, + } + if _, err := a.WalletCreateWallet(a0); err != nil { t.Fatal(err) } } -// Test_UnsetAssetContent tests the "unset_asset_content" method on the "wallet" canister. -func Test_UnsetAssetContent(t *testing.T) { +// Test_WalletCreateWallet128 tests the "wallet_create_wallet128" method on the "wallet" canister. +func Test_WalletCreateWallet128(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "unset_asset_content", - Arguments: []any{new(wallet.UnsetAssetContentArguments)}, + Name: "wallet_create_wallet128", + Arguments: []any{new(wallet.CreateCanisterArgs128)}, Handler: func(request mock.Request) ([]any, error) { - return []any{}, nil + return []any{wallet.WalletResultCreate{ + Ok: idl.Ptr(struct { + CanisterId principal.Principal `ic:"canister_id" json:"canister_id"` + }{ + *new(principal.Principal), + }), + }}, nil }, }, }) @@ -853,26 +848,30 @@ func Test_UnsetAssetContent(t *testing.T) { t.Fatal(err) } - var a0 = wallet.UnsetAssetContentArguments{ - *new(string), - *new(string), + var a0 = wallet.CreateCanisterArgs128{ + idl.NewNat(uint(0)), + wallet.CanisterSettings{ + *new(*principal.Principal), + *new(*[]principal.Principal), + *new(*idl.Nat), + *new(*idl.Nat), + *new(*idl.Nat), + }, } - if err := a.UnsetAssetContent(a0); err != nil { + if _, err := a.WalletCreateWallet128(a0); err != nil { t.Fatal(err) } } -// Test_ValidateCommitProposedBatch tests the "validate_commit_proposed_batch" method on the "wallet" canister. -func Test_ValidateCommitProposedBatch(t *testing.T) { +// Test_WalletReceive tests the "wallet_receive" method on the "wallet" canister. +func Test_WalletReceive(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "validate_commit_proposed_batch", - Arguments: []any{new(wallet.CommitProposedBatchArguments)}, + Name: "wallet_receive", + Arguments: []any{new(*wallet.ReceiveOptions)}, Handler: func(request mock.Request) ([]any, error) { - return []any{wallet.ValidationResult{ - Ok: new(string), - }}, nil + return []any{}, nil }, }, }) @@ -880,25 +879,25 @@ func Test_ValidateCommitProposedBatch(t *testing.T) { t.Fatal(err) } - var a0 = wallet.CommitProposedBatchArguments{ - idl.NewNat(uint(0)), - *new([]byte), - } - if _, err := a.ValidateCommitProposedBatch(a0); err != nil { + var a0 = *new(*wallet.ReceiveOptions) + if err := a.WalletReceive(a0); err != nil { t.Fatal(err) } } -// Test_ValidateGrantPermission tests the "validate_grant_permission" method on the "wallet" canister. -func Test_ValidateGrantPermission(t *testing.T) { +// Test_WalletSend tests the "wallet_send" method on the "wallet" canister. +func Test_WalletSend(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "validate_grant_permission", - Arguments: []any{new(wallet.GrantPermission)}, + Name: "wallet_send", + Arguments: []any{new(struct { + Canister principal.Principal `ic:"canister" json:"canister"` + Amount uint64 `ic:"amount" json:"amount"` + })}, Handler: func(request mock.Request) ([]any, error) { - return []any{wallet.ValidationResult{ - Ok: new(string), + return []any{wallet.WalletResult{ + Ok: new(idl.Null), }}, nil }, }, @@ -907,27 +906,31 @@ func Test_ValidateGrantPermission(t *testing.T) { t.Fatal(err) } - var a0 = wallet.GrantPermission{ + var a0 = struct { + Canister principal.Principal `ic:"canister" json:"canister"` + Amount uint64 `ic:"amount" json:"amount"` + }{ *new(principal.Principal), - wallet.Permission{ - Commit: new(idl.Null), - }, + *new(uint64), } - if _, err := a.ValidateGrantPermission(a0); err != nil { + if _, err := a.WalletSend(a0); err != nil { t.Fatal(err) } } -// Test_ValidateRevokePermission tests the "validate_revoke_permission" method on the "wallet" canister. -func Test_ValidateRevokePermission(t *testing.T) { +// Test_WalletSend128 tests the "wallet_send128" method on the "wallet" canister. +func Test_WalletSend128(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "validate_revoke_permission", - Arguments: []any{new(wallet.RevokePermission)}, + Name: "wallet_send128", + Arguments: []any{new(struct { + Canister principal.Principal `ic:"canister" json:"canister"` + Amount idl.Nat `ic:"amount" json:"amount"` + })}, Handler: func(request mock.Request) ([]any, error) { - return []any{wallet.ValidationResult{ - Ok: new(string), + return []any{wallet.WalletResult{ + Ok: new(idl.Null), }}, nil }, }, @@ -936,28 +939,29 @@ func Test_ValidateRevokePermission(t *testing.T) { t.Fatal(err) } - var a0 = wallet.RevokePermission{ + var a0 = struct { + Canister principal.Principal `ic:"canister" json:"canister"` + Amount idl.Nat `ic:"amount" json:"amount"` + }{ *new(principal.Principal), - wallet.Permission{ - Commit: new(idl.Null), - }, + idl.NewNat(uint(0)), } - if _, err := a.ValidateRevokePermission(a0); err != nil { + if _, err := a.WalletSend128(a0); err != nil { t.Fatal(err) } } -// Test_ValidateTakeOwnership tests the "validate_take_ownership" method on the "wallet" canister. -func Test_ValidateTakeOwnership(t *testing.T) { +// Test_WalletStoreWalletWasm tests the "wallet_store_wallet_wasm" method on the "wallet" canister. +func Test_WalletStoreWalletWasm(t *testing.T) { a, err := newAgent([]mock.Method{ { - Name: "validate_take_ownership", - Arguments: []any{}, + Name: "wallet_store_wallet_wasm", + Arguments: []any{new(struct { + WasmModule []byte `ic:"wasm_module" json:"wasm_module"` + })}, Handler: func(request mock.Request) ([]any, error) { - return []any{wallet.ValidationResult{ - Ok: new(string), - }}, nil + return []any{}, nil }, }, }) @@ -965,7 +969,12 @@ func Test_ValidateTakeOwnership(t *testing.T) { t.Fatal(err) } - if _, err := a.ValidateTakeOwnership(); err != nil { + var a0 = struct { + WasmModule []byte `ic:"wasm_module" json:"wasm_module"` + }{ + *new([]byte), + } + if err := a.WalletStoreWalletWasm(a0); err != nil { t.Fatal(err) } diff --git a/ic/wallet/types.mo b/ic/wallet/types.mo index fae4e91..3a6be74 100755 --- a/ic/wallet/types.mo +++ b/ic/wallet/types.mo @@ -1,29 +1,28 @@ // Do NOT edit this file. It was automatically generated by https://github.com/aviate-labs/agent-go. module T { - public type BatchId = Nat; - public type ChunkId = Nat; - public type Key = Text; - public type Time = Int; - public type CreateAssetArguments = { key : T.Key; content_type : Text; max_age : ?Nat64; headers : ?[T.HeaderField]; enable_aliasing : ?Bool; allow_raw_access : ?Bool }; - public type SetAssetContentArguments = { key : T.Key; content_encoding : Text; chunk_ids : [T.ChunkId]; sha256 : ?Blob }; - public type UnsetAssetContentArguments = { key : T.Key; content_encoding : Text }; - public type DeleteAssetArguments = { key : T.Key }; - public type ClearArguments = { }; - public type BatchOperationKind = { #CreateAsset : T.CreateAssetArguments; #SetAssetContent : T.SetAssetContentArguments; #SetAssetProperties : T.SetAssetPropertiesArguments; #UnsetAssetContent : T.UnsetAssetContentArguments; #DeleteAsset : T.DeleteAssetArguments; #Clear : T.ClearArguments }; - public type CommitBatchArguments = { batch_id : T.BatchId; operations : [T.BatchOperationKind] }; - public type CommitProposedBatchArguments = { batch_id : T.BatchId; evidence : Blob }; - public type ComputeEvidenceArguments = { batch_id : T.BatchId; max_iterations : ?Nat16 }; - public type DeleteBatchArguments = { batch_id : T.BatchId }; + public type EventKind = { #CyclesSent : { to : Principal; amount : Nat64; refund : Nat64 }; #CyclesReceived : { from : Principal; amount : Nat64; memo : ?Text }; #AddressAdded : { id : Principal; name : ?Text; role : T.Role }; #AddressRemoved : { id : Principal }; #CanisterCreated : { canister : Principal; cycles : Nat64 }; #CanisterCalled : { canister : Principal; method_name : Text; cycles : Nat64 }; #WalletDeployed : { canister : Principal } }; + public type EventKind128 = { #CyclesSent : { to : Principal; amount : Nat; refund : Nat }; #CyclesReceived : { from : Principal; amount : Nat; memo : ?Text }; #AddressAdded : { id : Principal; name : ?Text; role : T.Role }; #AddressRemoved : { id : Principal }; #CanisterCreated : { canister : Principal; cycles : Nat }; #CanisterCalled : { canister : Principal; method_name : Text; cycles : Nat }; #WalletDeployed : { canister : Principal } }; + public type Event = { id : Nat32; timestamp : Nat64; kind : T.EventKind }; + public type Event128 = { id : Nat32; timestamp : Nat64; kind : T.EventKind128 }; + public type Role = { #Contact; #Custodian; #Controller }; + public type Kind = { #Unknown; #User; #Canister }; + public type AddressEntry = { id : Principal; name : ?Text; kind : T.Kind; role : T.Role }; + public type ManagedCanisterInfo = { id : Principal; name : ?Text; created_at : Nat64 }; + public type ManagedCanisterEventKind = { #CyclesSent : { amount : Nat64; refund : Nat64 }; #Called : { method_name : Text; cycles : Nat64 }; #Created : { cycles : Nat64 } }; + public type ManagedCanisterEventKind128 = { #CyclesSent : { amount : Nat; refund : Nat }; #Called : { method_name : Text; cycles : Nat }; #Created : { cycles : Nat } }; + public type ManagedCanisterEvent = { id : Nat32; timestamp : Nat64; kind : T.ManagedCanisterEventKind }; + public type ManagedCanisterEvent128 = { id : Nat32; timestamp : Nat64; kind : T.ManagedCanisterEventKind128 }; + public type ReceiveOptions = { memo : ?Text }; + public type WalletResultCreate = { #Ok : { canister_id : Principal }; #Err : Text }; + public type WalletResult = { #Ok : (); #Err : Text }; + public type WalletResultCall = { #Ok : { return : Blob }; #Err : Text }; + public type CanisterSettings = { controller : ?Principal; controllers : ?[Principal]; compute_allocation : ?Nat; memory_allocation : ?Nat; freezing_threshold : ?Nat }; + public type CreateCanisterArgs = { cycles : Nat64; settings : T.CanisterSettings }; + public type CreateCanisterArgs128 = { cycles : Nat; settings : T.CanisterSettings }; public type HeaderField = (Text, Text); - public type HttpRequest = { method : Text; url : Text; headers : [T.HeaderField]; body : Blob; certificate_version : ?Nat16 }; + public type HttpRequest = { method : Text; url : Text; headers : [T.HeaderField]; body : Blob }; public type HttpResponse = { status_code : Nat16; headers : [T.HeaderField]; body : Blob; streaming_strategy : ?T.StreamingStrategy }; - public type StreamingCallbackHttpResponse = { body : Blob; token : ?T.StreamingCallbackToken }; - public type StreamingCallbackToken = { key : T.Key; content_encoding : Text; index : Nat; sha256 : ?Blob }; - public type StreamingStrategy = { #Callback : { callback : { /* func */ }; token : T.StreamingCallbackToken } }; - public type SetAssetPropertiesArguments = { key : T.Key; max_age : ??Nat64; headers : ??[T.HeaderField]; allow_raw_access : ??Bool; is_aliased : ??Bool }; - public type Permission = { #Commit; #ManagePermissions; #Prepare }; - public type GrantPermission = { to_principal : Principal; permission : T.Permission }; - public type RevokePermission = { of_principal : Principal; permission : T.Permission }; - public type ListPermitted = { permission : T.Permission }; - public type ValidationResult = { #Ok : Text; #Err : Text }; + public type StreamingCallbackHttpResponse = { body : Blob; token : ?T.Token }; + public type Token = { }; + public type StreamingStrategy = { #Callback : { callback : { /* func */ }; token : T.Token } }; };