Skip to content

Commit

Permalink
Merge branch 'aptos-labs:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
meslubi2021 authored Jan 7, 2025
2 parents 1b47e8f + a6e0c22 commit 11468be
Show file tree
Hide file tree
Showing 21 changed files with 234 additions and 236 deletions.
2 changes: 1 addition & 1 deletion .config/dotnet-tools.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
"rollForward": false
},
"csharpier": {
"version": "0.29.2",
"version": "0.30.5",
"commands": ["dotnet-csharpier"],
"rollForward": false
}
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/api-reference.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ jobs:
run: docfx docfx.json

- name: Upload artifact
uses: actions/upload-pages-artifact@v4
uses: actions/upload-pages-artifact@v3
with:
path: "_site"

Expand Down
12 changes: 4 additions & 8 deletions Aptos.Indexer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,14 +19,10 @@ public static async Task Main(string[] args)

IAptosIndexerClient client = services.GetRequiredService<IAptosIndexerClient>();

Dictionary<string, object?> variables =
new()
{
{
"address",
"0x1affcf8d0a23b937c244236486ae43d05f7c821ef7abb0b5ca11cdc2a5aff18d"
},
};
Dictionary<string, object?> variables = new()
{
{ "address", "0x1affcf8d0a23b937c244236486ae43d05f7c821ef7abb0b5ca11cdc2a5aff18d" },
};

var result = await client.GetAccountTransactionsCount.ExecuteAsync(
"0x1affcf8d0a23b937c244236486ae43d05f7c821ef7abb0b5ca11cdc2a5aff18d"
Expand Down
163 changes: 80 additions & 83 deletions Aptos.Tests/Aptos.Transactions/TypeTag.Parser.Tests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,94 +7,91 @@ public class TypeTagParserTests(ITestOutputHelper output) : BaseTests(output)
{
const string TAG_STRUCT_NAME = "0x1::tag::Tag";

readonly Dictionary<string, TypeTag> primitiveTypesDict =
new()
{
{ "bool", new TypeTagBool() },
{ "address", new TypeTagAddress() },
{ "signer", new TypeTagSigner() },
{ "u8", new TypeTagU8() },
{ "u16", new TypeTagU16() },
{ "u32", new TypeTagU32() },
{ "u64", new TypeTagU64() },
{ "u128", new TypeTagU128() },
{ "u256", new TypeTagU256() },
};
readonly Dictionary<string, TypeTag> primitiveTypesDict = new()
{
{ "bool", new TypeTagBool() },
{ "address", new TypeTagAddress() },
{ "signer", new TypeTagSigner() },
{ "u8", new TypeTagU8() },
{ "u16", new TypeTagU16() },
{ "u32", new TypeTagU32() },
{ "u64", new TypeTagU64() },
{ "u128", new TypeTagU128() },
{ "u256", new TypeTagU256() },
};

readonly Dictionary<string, TypeTag> structTypesDict =
new()
readonly Dictionary<string, TypeTag> structTypesDict = new()
{
{ "0x1::string::String", new TypeTagStruct(new StructTag(StructTag.STRING)) },
{
{ "0x1::string::String", new TypeTagStruct(new StructTag(StructTag.STRING)) },
{
"0x1::aptos_coin::AptosCoin",
new TypeTagStruct(
new StructTag(AccountAddress.FromString("0x1"), "aptos_coin", "AptosCoin")
)
},
{
"0x1::option::Option<u8>",
new TypeTagStruct(new StructTag(StructTag.OPTION, [new TypeTagU8()]))
},
{
"0x1::object::Object<u8>",
new TypeTagStruct(new StructTag(StructTag.OBJECT, [new TypeTagU8()]))
},
{ $"{TAG_STRUCT_NAME}", new TypeTagStruct(new StructTag(StructTag.TAG)) },
{
$"{TAG_STRUCT_NAME}<u8>",
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU8()]))
},
{
$"{TAG_STRUCT_NAME}<u8, u8>",
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU8(), new TypeTagU8()]))
},
{
$"{TAG_STRUCT_NAME}<u64, u8>",
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU64(), new TypeTagU8()]))
},
{
$"{TAG_STRUCT_NAME}<{TAG_STRUCT_NAME}<u8>, u8>",
new TypeTagStruct(
new StructTag(
StructTag.TAG,
[
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU8()])),
new TypeTagU8(),
]
)
"0x1::aptos_coin::AptosCoin",
new TypeTagStruct(
new StructTag(AccountAddress.FromString("0x1"), "aptos_coin", "AptosCoin")
)
},
{
"0x1::option::Option<u8>",
new TypeTagStruct(new StructTag(StructTag.OPTION, [new TypeTagU8()]))
},
{
"0x1::object::Object<u8>",
new TypeTagStruct(new StructTag(StructTag.OBJECT, [new TypeTagU8()]))
},
{ $"{TAG_STRUCT_NAME}", new TypeTagStruct(new StructTag(StructTag.TAG)) },
{
$"{TAG_STRUCT_NAME}<u8>",
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU8()]))
},
{
$"{TAG_STRUCT_NAME}<u8, u8>",
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU8(), new TypeTagU8()]))
},
{
$"{TAG_STRUCT_NAME}<u64, u8>",
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU64(), new TypeTagU8()]))
},
{
$"{TAG_STRUCT_NAME}<{TAG_STRUCT_NAME}<u8>, u8>",
new TypeTagStruct(
new StructTag(
StructTag.TAG,
[
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU8()])),
new TypeTagU8(),
]
)
},
{
$"{TAG_STRUCT_NAME}<u8, {TAG_STRUCT_NAME}<u8>>",
new TypeTagStruct(
new StructTag(
StructTag.TAG,
[
new TypeTagU8(),
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU8()])),
]
)
)
},
{
$"{TAG_STRUCT_NAME}<u8, {TAG_STRUCT_NAME}<u8>>",
new TypeTagStruct(
new StructTag(
StructTag.TAG,
[
new TypeTagU8(),
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagU8()])),
]
)
},
};
)
},
};

readonly Dictionary<string, TypeTag> genericTypesDict =
new()
{
{ "T0", new TypeTagGeneric(0) },
{ "T1", new TypeTagGeneric(1) },
{ "T1337", new TypeTagGeneric(1337) },
{
$"{TAG_STRUCT_NAME}<T0>",
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagGeneric(0)]))
},
{
$"{TAG_STRUCT_NAME}<T0, T1>",
new TypeTagStruct(
new StructTag(StructTag.TAG, [new TypeTagGeneric(0), new TypeTagGeneric(1)])
)
},
};
readonly Dictionary<string, TypeTag> genericTypesDict = new()
{
{ "T0", new TypeTagGeneric(0) },
{ "T1", new TypeTagGeneric(1) },
{ "T1337", new TypeTagGeneric(1337) },
{
$"{TAG_STRUCT_NAME}<T0>",
new TypeTagStruct(new StructTag(StructTag.TAG, [new TypeTagGeneric(0)]))
},
{
$"{TAG_STRUCT_NAME}<T0, T1>",
new TypeTagStruct(
new StructTag(StructTag.TAG, [new TypeTagGeneric(0), new TypeTagGeneric(1)])
)
},
};

private Dictionary<string, TypeTag> mergedTypes =>
primitiveTypesDict
Expand Down
9 changes: 4 additions & 5 deletions Aptos/Aptos.Api/AccountSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,11 +13,10 @@ public abstract class AccountSignature(SigningScheme type)

public class AccountSignatureConverter : JsonConverter<AccountSignature>
{
static readonly JsonSerializerSettings SpecifiedSubclassConversion =
new()
{
ContractResolver = new SubclassSpecifiedConcreteClassConverter<AccountSignature>(),
};
static readonly JsonSerializerSettings SpecifiedSubclassConversion = new()
{
ContractResolver = new SubclassSpecifiedConcreteClassConverter<AccountSignature>(),
};

public override AccountSignature? ReadJson(
JsonReader reader,
Expand Down
11 changes: 5 additions & 6 deletions Aptos/Aptos.Api/TransactionPayloadResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,11 @@ public class TransactionPayloadResponseConverter : JsonConverter<TransactionPayl
{
public override bool CanWrite => false;

static readonly JsonSerializerSettings SpecifiedSubclassConversion =
new()
{
ContractResolver =
new SubclassSpecifiedConcreteClassConverter<TransactionPayloadResponse>(),
};
static readonly JsonSerializerSettings SpecifiedSubclassConversion = new()
{
ContractResolver =
new SubclassSpecifiedConcreteClassConverter<TransactionPayloadResponse>(),
};

public override TransactionPayloadResponse? ReadJson(
JsonReader reader,
Expand Down
9 changes: 4 additions & 5 deletions Aptos/Aptos.Api/TransactionResponse.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,11 +45,10 @@ public class TransactionResponseConverter : JsonConverter<TransactionResponse>
{
public override bool CanWrite => false;

static readonly JsonSerializerSettings SpecifiedSubclassConversion =
new()
{
ContractResolver = new SubclassSpecifiedConcreteClassConverter<TransactionResponse>(),
};
static readonly JsonSerializerSettings SpecifiedSubclassConversion = new()
{
ContractResolver = new SubclassSpecifiedConcreteClassConverter<TransactionResponse>(),
};

public override TransactionResponse? ReadJson(
JsonReader reader,
Expand Down
9 changes: 4 additions & 5 deletions Aptos/Aptos.Api/TransactionSignature.cs
Original file line number Diff line number Diff line change
Expand Up @@ -35,11 +35,10 @@ public class TransactionSignatureConverter : JsonConverter<TransactionSignature>
{
public override bool CanWrite => false;

static readonly JsonSerializerSettings SpecifiedSubclassConversion =
new()
{
ContractResolver = new SubclassSpecifiedConcreteClassConverter<TransactionSignature>(),
};
static readonly JsonSerializerSettings SpecifiedSubclassConversion = new()
{
ContractResolver = new SubclassSpecifiedConcreteClassConverter<TransactionSignature>(),
};

public override TransactionSignature? ReadJson(
JsonReader reader,
Expand Down
6 changes: 4 additions & 2 deletions Aptos/Aptos.Api/WriteSet.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,10 @@ public abstract class WriteSet(string type)

public class WriteSetConverter : JsonConverter<WriteSet>
{
static readonly JsonSerializerSettings SpecifiedSubclassConversion =
new() { ContractResolver = new SubclassSpecifiedConcreteClassConverter<WriteSet>() };
static readonly JsonSerializerSettings SpecifiedSubclassConversion = new()
{
ContractResolver = new SubclassSpecifiedConcreteClassConverter<WriteSet>(),
};

public override WriteSet? ReadJson(
JsonReader reader,
Expand Down
6 changes: 4 additions & 2 deletions Aptos/Aptos.Api/WriteSetChange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@ public class WritesSetChangeConverter : JsonConverter<WriteSetChange>
{
public override bool CanWrite => false;

static readonly JsonSerializerSettings SpecifiedSubclassConversion =
new() { ContractResolver = new SubclassSpecifiedConcreteClassConverter<WriteSetChange>() };
static readonly JsonSerializerSettings SpecifiedSubclassConversion = new()
{
ContractResolver = new SubclassSpecifiedConcreteClassConverter<WriteSetChange>(),
};

public override WriteSetChange? ReadJson(
JsonReader reader,
Expand Down
6 changes: 4 additions & 2 deletions Aptos/Aptos.Clients/AccountClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,10 @@ await _client.DigitalAsset.GetAccountDigitalAssetOwnerships(
current_token_ownerships_v2_order_by? orderBy = null
)
{
current_token_ownerships_v2_bool_exp condition =
new() { Token_data_id = new() { _eq = tokenId } };
current_token_ownerships_v2_bool_exp condition = new()
{
Token_data_id = new() { _eq = tokenId },
};
if (where != null)
condition._and = [where];
return (
Expand Down
34 changes: 16 additions & 18 deletions Aptos/Aptos.Clients/AptosClient/AptosClient.Requests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,15 +85,14 @@ public async Task<AptosResponse<Res>> Request<Res>(ApiType type, AptosRequest re

aptosRequest.Url = request.Path != null ? $"{request.Url}/{request.Path}" : request.Url;

ClientRequest clientRequest =
new(
aptosRequest.Url,
aptosRequest.Method,
aptosRequest.Body,
aptosRequest.ContentType,
aptosRequest.QueryParams,
new Dictionary<string, string>(Config.Headers)
);
ClientRequest clientRequest = new(
aptosRequest.Url,
aptosRequest.Method,
aptosRequest.Body,
aptosRequest.ContentType,
aptosRequest.QueryParams,
new Dictionary<string, string>(Config.Headers)
);

// Add default headers
clientRequest.Headers ??= [];
Expand All @@ -106,15 +105,14 @@ public async Task<AptosResponse<Res>> Request<Res>(ApiType type, AptosRequest re

ClientResponse<Res> clientResponse = await ClientRequest<Res>(clientRequest);

AptosResponse<object> errorResponse =
new(
clientResponse.Status,
clientResponse.StatusText,
clientResponse.Error ?? new JObject(),
aptosRequest.Url,
clientResponse.Headers ?? [],
aptosRequest
);
AptosResponse<object> errorResponse = new(
clientResponse.Status,
clientResponse.StatusText,
clientResponse.Error ?? new JObject(),
aptosRequest.Url,
clientResponse.Headers ?? [],
aptosRequest
);

// Handle case for `401 Unauthorized` responses (e.g. provided API key is invalid)
if (clientResponse.Status == 401)
Expand Down
6 changes: 4 additions & 2 deletions Aptos/Aptos.Clients/DigitalAssetClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,8 +32,10 @@ public async Task<List<DigitalAssetOwnership>> GetAccountDigitalAssetOwnerships(
current_token_ownerships_v2_order_by? orderBy = null
)
{
current_token_ownerships_v2_bool_exp condition =
new() { Owner_address = new() { _eq = address } };
current_token_ownerships_v2_bool_exp condition = new()
{
Owner_address = new() { _eq = address },
};
if (where != null)
condition._and = [where];
return await GetDigitalAssetOwnerships(condition, offset, limit, orderBy);
Expand Down
6 changes: 4 additions & 2 deletions Aptos/Aptos.Clients/FungibleAssetClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -90,8 +90,10 @@ public async Task<List<FungibleAssetBalance>> GetAccountFungibleAssetBalances(
current_fungible_asset_balances_order_by? orderBy = null
)
{
current_fungible_asset_balances_bool_exp condition =
new() { Owner_address = new() { _eq = address } };
current_fungible_asset_balances_bool_exp condition = new()
{
Owner_address = new() { _eq = address },
};
if (where != null)
condition._and = [where];
return await GetFungibleAssetBalances(condition, offset, limit, orderBy);
Expand Down
Loading

0 comments on commit 11468be

Please sign in to comment.