Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enhance tangle-substrate-types & Fix Auto Release Issues #791

Merged
merged 9 commits into from
Oct 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 31 additions & 10 deletions .github/workflows/publish-types.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,31 +9,52 @@ on:
branches:
- main
paths:
- 'types/src/**'
- 'types/package.json'
- 'types/src/interfaces/**'
- 'types/src/index.ts'

permissions:
contents: write
id-token: write

jobs:
build:
runs-on: ubuntu-latest
permissions:
packages: write
contents: read

steps:
- uses: actions/checkout@master
with:
token: ${{ secrets.GITHUB_TOKEN }}

- uses: actions/setup-node@v3
with:
node-version: '18.x'
registry-url: 'https://registry.npmjs.org'
- name: Install npm dependencies
run: cd types && yarn install

# Configure SSH with private SSH key
- name: Attach SSH key
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.GIT_SSH_PRIVATE_KEY }}

- name: Configure Github Actions user
run: |
git config --global user.email "${GITHUB_ACTOR}@users.noreply.github.com"
git config --global user.name "${GITHUB_ACTOR}"

- name: Initialize the NPM config
run: npm config set //registry.npmjs.org/:_authToken $NPM_TOKEN
env:
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: Install npm dependencies
run: |
cd types
yarn install

- name: Publish the package
run: cd types && yarn publish-types --ci
run: |
cd types
yarn publish-types --ci
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.RELEASE_IT_GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ chainspecs/standalone-local.json

# NodeJS
**/node_modules/
**.npmrc
types/build
types/ts-types

Expand Down
11 changes: 8 additions & 3 deletions node/src/rpc/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,9 +41,9 @@ use tangle_runtime::BlockNumber;

// Runtime
#[cfg(not(feature = "testnet"))]
use tangle_runtime::{AccountId, Balance, Hash, Index, PalletServicesConstraints};
use tangle_runtime::{AccountId, AssetId, Balance, Hash, Index, PalletServicesConstraints};
#[cfg(feature = "testnet")]
use tangle_testnet_runtime::{AccountId, Balance, Hash, Index, PalletServicesConstraints};
use tangle_testnet_runtime::{AccountId, AssetId, Balance, Hash, Index, PalletServicesConstraints};

pub mod eth;
pub mod tracing;
Expand Down Expand Up @@ -117,7 +117,12 @@ where
C::Api: substrate_frame_rpc_system::AccountNonceApi<Block, AccountId, Index>,
C::Api: sp_block_builder::BlockBuilder<Block>,
C::Api: pallet_transaction_payment_rpc::TransactionPaymentRuntimeApi<Block, Balance>,
C::Api: pallet_services_rpc::ServicesRuntimeApi<Block, PalletServicesConstraints, AccountId>,
C::Api: pallet_services_rpc::ServicesRuntimeApi<
Block,
PalletServicesConstraints,
AccountId,
AssetId,
>,
C::Api: fp_rpc::ConvertTransactionRuntimeApi<Block>,
C::Api: fp_rpc::EthereumRuntimeRPCApi<Block>,
C::Api: rpc_primitives_debug::DebugRuntimeApi<Block>,
Expand Down
8 changes: 7 additions & 1 deletion scripts/run-standalone-local.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ for port in ${ports[@]}; do
done

CLEAN=${CLEAN:-false}
ARCHIVE=${ARCHIVE:-false}
# Parse arguments for the script

while [[ $# -gt 0 ]]; do
Expand All @@ -24,6 +25,10 @@ while [[ $# -gt 0 ]]; do
CLEAN=true
shift # past argument
;;
--archive)
ARCHIVE=true
shift # past argument
;;
*) # unknown option
shift # past argument
;;
Expand Down Expand Up @@ -54,7 +59,8 @@ echo "*** Start Tangle Testnet ***"
--rpc-max-response-size 3000 \
--ethapi trace,debug \
--auto-insert-keys \
--node-key 0000000000000000000000000000000000000000000000000000000000000001 &
--node-key 0000000000000000000000000000000000000000000000000000000000000001 \
$([ "$ARCHIVE" = true ] && echo "--pruning=archive") &
# Sleep for a while to allow the node to start
sleep 3
# Bob
Expand Down
4 changes: 4 additions & 0 deletions types/.release-it.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,14 @@ export default {
commitMessage: 'Release `tangle-substrate-types` v${version}',
tagName: '${npm.name}/v${version}',
tagAnnotation: 'Release ${npm.name} v${version}',
pushRepo: '[email protected]:tangle-network/tangle.git',
},
github: {
release: true,
releaseName: 'Release ${npm.name} v${version}',
releaseNotes(context) {
return `Release ${context.npm.name} version ${context.version}`
},
},
npm: {
publish: true,
Expand Down
18 changes: 12 additions & 6 deletions types/package.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,14 @@
{
"name": "@webb-tools/tangle-substrate-types",
"version": "0.5.13",
"version": "0.9.0",
"description": "Polkadot.js type definitions required for interacting with Webb's tangle network",
"author": "Webb Developers <[email protected]>",
"license": "Apache-2.0",
"repository": "https://github.com/webb-tools/tangle.git",
"homepage": "https://github.com/webb-tools/tangle",
"repository": {
"type": "git",
"url": "git+https://github.com/tangle-network/tangle.git"
},
"homepage": "https://github.com/tangle-network/tangle",
"files": [
"build"
],
Expand All @@ -25,7 +28,7 @@
"registry": "https://registry.npmjs.org"
},
"bugs": {
"url": "https://github.com/webb-tools/tangle/issues"
"url": "https://github.com/tangle-network/tangle/issues"
},
"scripts": {
"build": "bunchee",
Expand All @@ -34,7 +37,8 @@
"build:interfaces:chain": "tsx node_modules/.bin/polkadot-types-from-chain --output ./src/interfaces --package @webb-tools/tangle-substrate-types --endpoint ws://127.0.0.1:9944",
"clean": "rm -rf build",
"publish-types": "release-it patch",
"update:metadata": "tsx ./scripts/updateMetadata.ts"
"update:metadata": "tsx ./scripts/updateMetadata.ts",
"prepare": "ts-patch install -s"
},
"dependencies": {
"@polkadot/api": "^13.2.1",
Expand All @@ -46,11 +50,13 @@
"devDependencies": {
"@types/node": "^22.6.1",
"@types/ws": "^8.5.12",
"bunchee": "^5.4.0",
"bunchee": "^5.5.1",
"prettier": "3.2.5",
"release-it": "^17.6.0",
"ts-patch": "^3.2.1",
"tsx": "^4.19.1",
"typescript": "5.4.2",
"typescript-transform-paths": "^3.5.1",
"ws": "^8.18.0"
},
"packageManager": "[email protected]+sha512.a6b2f7906b721bba3d67d4aff083df04dad64c399707841b7acf00f6b133b7ac24255f2652fa22ae3534329dc6180534e98d17432037ff6fd140556e2bb3137e"
Expand Down
43 changes: 39 additions & 4 deletions types/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,42 @@
// Copyright (C) 2022-2024 Webb Technologies Inc.
// SPDX-License-Identifier: Apache-2.0

import './interfaces'
import './interfaces/augment-api.js'
import './interfaces/augment-types.js'
import './interfaces/types-lookup.js'
import './interfaces/augment-api'
import './interfaces/augment-types'
import './interfaces/types-lookup'

import type {
OverrideBundleDefinition,
OverrideBundleType,
} from '@polkadot/types/types'

import * as tangleDefs from './interfaces/definitions'
import { jsonrpcFromDefs, typesAliasFromDefs, typesFromDefs } from './utils'

export * as tangleLookupTypes from './interfaces/lookup'

export const tangleTypes = typesFromDefs(tangleDefs)
export const tangleRpc = jsonrpcFromDefs(tangleDefs, {})
export const tangleTypesAlias = typesAliasFromDefs(tangleDefs, {})

const sharedBundle: OverrideBundleDefinition = {
rpc: tangleRpc,
types: [
{
minmax: [],
types: tangleTypes,
},
],
alias: tangleTypesAlias,
}

export const tangleTypesBundle: OverrideBundleType = {
chain: {
tangle: sharedBundle,
},
spec: {
tangle: sharedBundle,
},
}

export const typesBundleForPolkadot = tangleTypesBundle
4 changes: 4 additions & 0 deletions types/src/interfaces/augment-api-consts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -712,6 +712,10 @@ declare module '@polkadot/api-base/types/consts' {
[key: string]: Codec;
};
services: {
/**
* Maximum number of assets per service.
**/
maxAssetsPerService: u32 & AugmentedConst<ApiType>;
/**
* Maximum number of binaries per gadget.
**/
Expand Down
8 changes: 8 additions & 0 deletions types/src/interfaces/augment-api-errors.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1503,6 +1503,10 @@ declare module '@polkadot/api-base/types/errors' {
* blueprint.
**/
JobDefinitionNotFound: AugmentedError<ApiType>;
/**
* The maximum number of assets per service has been exceeded.
**/
MaxAssetsPerServiceExceeded: AugmentedError<ApiType>;
/**
* The maximum number of fields per request has been exceeded.
**/
Expand All @@ -1523,6 +1527,10 @@ declare module '@polkadot/api-base/types/errors' {
* The maximum number of services per user has been exceeded.
**/
MaxServicesPerUserExceeded: AugmentedError<ApiType>;
/**
* No assets provided for the service, at least one asset is required.
**/
NoAssetsProvided: AugmentedError<ApiType>;
/**
* The caller is not registered as a operator.
**/
Expand Down
4 changes: 2 additions & 2 deletions types/src/interfaces/augment-api-events.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1128,15 +1128,15 @@ declare module '@polkadot/api-base/types/events' {
/**
* A service has been initiated.
**/
ServiceInitiated: AugmentedEvent<ApiType, [owner: AccountId32, requestId: Option<u64>, serviceId: u64, blueprintId: u64], { owner: AccountId32, requestId: Option<u64>, serviceId: u64, blueprintId: u64 }>;
ServiceInitiated: AugmentedEvent<ApiType, [owner: AccountId32, requestId: Option<u64>, serviceId: u64, blueprintId: u64, assets: Vec<u128>], { owner: AccountId32, requestId: Option<u64>, serviceId: u64, blueprintId: u64, assets: Vec<u128> }>;
/**
* A service request has been approved.
**/
ServiceRequestApproved: AugmentedEvent<ApiType, [operator: AccountId32, requestId: u64, blueprintId: u64, pendingApprovals: Vec<AccountId32>, approved: Vec<AccountId32>], { operator: AccountId32, requestId: u64, blueprintId: u64, pendingApprovals: Vec<AccountId32>, approved: Vec<AccountId32> }>;
/**
* A new service has been requested.
**/
ServiceRequested: AugmentedEvent<ApiType, [owner: AccountId32, requestId: u64, blueprintId: u64, pendingApprovals: Vec<AccountId32>, approved: Vec<AccountId32>], { owner: AccountId32, requestId: u64, blueprintId: u64, pendingApprovals: Vec<AccountId32>, approved: Vec<AccountId32> }>;
ServiceRequested: AugmentedEvent<ApiType, [owner: AccountId32, requestId: u64, blueprintId: u64, pendingApprovals: Vec<AccountId32>, approved: Vec<AccountId32>, assets: Vec<u128>], { owner: AccountId32, requestId: u64, blueprintId: u64, pendingApprovals: Vec<AccountId32>, approved: Vec<AccountId32>, assets: Vec<u128> }>;
/**
* A service request has been rejected.
**/
Expand Down
2 changes: 1 addition & 1 deletion types/src/interfaces/augment-api-tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3158,7 +3158,7 @@ declare module '@polkadot/api-base/types/submittable' {
* `ApprovalPreference::Required` you will need to wait until they are approve your
* request, otherwise (if none), the service is initiated immediately.
**/
request: AugmentedSubmittable<(blueprintId: Compact<u64> | AnyNumber | Uint8Array, permittedCallers: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[], serviceProviders: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[], ttl: Compact<u64> | AnyNumber | Uint8Array, requestArgs: Vec<TanglePrimitivesServicesField> | (TanglePrimitivesServicesField | { None: any } | { Bool: any } | { Uint8: any } | { Int8: any } | { Uint16: any } | { Int16: any } | { Uint32: any } | { Int32: any } | { Uint64: any } | { Int64: any } | { String: any } | { Bytes: any } | { Array: any } | { List: any } | { Struct: any } | { AccountId: any } | string | Uint8Array)[]) => SubmittableExtrinsic<ApiType>, [Compact<u64>, Vec<AccountId32>, Vec<AccountId32>, Compact<u64>, Vec<TanglePrimitivesServicesField>]>;
request: AugmentedSubmittable<(blueprintId: Compact<u64> | AnyNumber | Uint8Array, permittedCallers: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[], serviceProviders: Vec<AccountId32> | (AccountId32 | string | Uint8Array)[], requestArgs: Vec<TanglePrimitivesServicesField> | (TanglePrimitivesServicesField | { None: any } | { Bool: any } | { Uint8: any } | { Int8: any } | { Uint16: any } | { Int16: any } | { Uint32: any } | { Int32: any } | { Uint64: any } | { Int64: any } | { String: any } | { Bytes: any } | { Array: any } | { List: any } | { Struct: any } | { AccountId: any } | string | Uint8Array)[], assets: Vec<u128> | (u128 | AnyNumber | Uint8Array)[], ttl: Compact<u64> | AnyNumber | Uint8Array) => SubmittableExtrinsic<ApiType>, [Compact<u64>, Vec<AccountId32>, Vec<AccountId32>, Vec<TanglePrimitivesServicesField>, Vec<u128>, Compact<u64>]>;
/**
* Submit the job result by using the service ID and call ID.
**/
Expand Down
Loading
Loading