Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into feat/gateway-coverage
Browse files Browse the repository at this point in the history
milapsheth authored Aug 21, 2024
2 parents f5a27b7 + b351d5f commit c5e5322
Showing 24 changed files with 939 additions and 727 deletions.
5 changes: 0 additions & 5 deletions .changeset/itchy-geese-reply.md

This file was deleted.

39 changes: 39 additions & 0 deletions .github/workflows/create-release-pr.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Create Release Pull Request

on:
workflow_dispatch:

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
SUI_VERSION: mainnet-v1.25.3

jobs:
release-pr:
name: Create Release Pull Request
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Install dependencies
shell: bash
run: npm ci

- name: Check for changeset files
id: check-changeset-files
run: |
if ls .changeset/*.md | grep '\.changeset\/[a-z-]\+\.md$'; then
echo "has_changeset_files=true" >> "$GITHUB_OUTPUT"
else
echo "has_changeset_files=false" >> "$GITHUB_OUTPUT"
fi
- name: Create Release Pull Request
if: steps.check-changeset-files.outputs.has_changeset_files == 'true'
uses: changesets/action@v1
with:
title: 'chore: bump version and update changelog'
createGithubReleases: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
Original file line number Diff line number Diff line change
@@ -1,43 +1,49 @@
name: Release
name: Publish to NPM

on:
workflow_dispatch:
pull_request:
branches:
- main
types:
- closed

concurrency: ${{ github.workflow }}-${{ github.ref }}

env:
SUI_VERSION: mainnet-v1.25.3

jobs:
release:
name: Release
publish:
name: Publish to NPM
if: >
github.event.pull_request.merged == true &&
github.event.pull_request.user.login == 'github-actions[bot]'
runs-on: ubuntu-latest
steps:
- name: Checkout Repo
uses: actions/checkout@v4

- name: Check for changeset files
id: checkfile
id: check-changeset-files
run: |
if ls .changeset/*.md | grep '\.changeset\/[a-z-]\+\.md$'; then
echo "has_file=true" >> "$GITHUB_OUTPUT"
echo "has_changeset_files=true" >> "$GITHUB_OUTPUT"
else
echo "has_file=false" >> "$GITHUB_OUTPUT"
echo "has_changeset_files=false" >> "$GITHUB_OUTPUT"
fi
- name: Setup Sui CLI and install dependencies
uses: ./.github/actions/install
with:
SUI_VERSION: ${{ env.SUI_VERSION }}

- name: Create Release Pull Request
if: steps.checkfile.outputs.has_file == 'true'
- name: Create GitHub Release
if: steps.check-changeset-files.outputs.has_changeset_files == 'false'
uses: changesets/action@v1
with:
title: 'release: bump version and publish to npm'
commit: 'chore: bump version and update changelog'
publish: npm run release
createGithubReleases: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -68,5 +68,10 @@ target/
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb

# dist
dist
# move_compile
move_compile/

# binaries
sui-binaries/
18 changes: 18 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,23 @@
# @axelar-network/axelar-cgp-sui

## 0.4.0

### Minor Changes

- 523e24c: Use hot potato pattern with `sui::borrow` package for loan out a capabilities in operators contract.

### Patch Changes

- 86d7fa3: Include gas payment into test contract's `send_call` function
- ab7235b: Remove postinstall script and src directory from published content

## 0.3.1

### Patch Changes

- 86d7fa3: Include gas payment into test contract's `send_call` function
- ab7235b: Remove postinstall script and src directory from published content

## 0.3.0

### Minor Changes
11 changes: 7 additions & 4 deletions docs/release.md
Original file line number Diff line number Diff line change
@@ -28,14 +28,17 @@ git commit -m "chore: update changeset"
git push
```

### 3. Trigger the Release Workflow
### 3. Trigger the Create Release Pull Request Workflow

Trigger the release workflow [here](https://github.com/axelarnetwork/axelar-cgp-sui/actions/workflows/release.yaml) when you want to publish the package. The release PR will be created. This PR will:
Trigger the [Create Release Pull Request](https://github.com/axelarnetwork/axelar-cgp-sui/actions/workflows/create-release-pr.yaml) workflow when you want to publish the package. The release PR will be created. This PR will:

- Update the `CHANGELOG.md` file with the changes made in the release.
- Bump the version number of the package.
- Publish the package to NPM.
- Create a new GitHub release.

After this PR is merged, the [Publish to NPM](https://github.com/axelarnetwork/axelar-cgp-sui/actions/workflows/publish-to-npm.yaml) workflow will be triggered and the following things will happen:

- The package will be published to npm.
- Create a new GitHub release with the changes made in the release.

## Release Snapshot Versions

31 changes: 22 additions & 9 deletions move/its/sources/coin_info.move
Original file line number Diff line number Diff line change
@@ -6,33 +6,38 @@ module its::coin_info {
use std::ascii;
use std::string::String;

use sui::coin::{Self, CoinMetadata};
use sui::coin::CoinMetadata;

use its::utils;

public struct CoinInfo<phantom T> has store {
name: String,
symbol: ascii::String,
decimals: u8,
remote_decimals: u8,
metadata: Option<CoinMetadata<T>>,
}

/// Create a new coin info from the given name, symbol and decimals.
public fun from_info<T>(
name: String, symbol: ascii::String, decimals: u8
name: String, symbol: ascii::String, decimals: u8, remote_decimals: u8,
): CoinInfo<T> {
CoinInfo {
name,
symbol,
decimals,
remote_decimals,
metadata: option::none(),
}
}

/// Create a new coin info from the given `CoinMetadata` object.
public fun from_metadata<T>(metadata: CoinMetadata<T>): CoinInfo<T> {
public fun from_metadata<T>(metadata: CoinMetadata<T>, remote_decimals: u8): CoinInfo<T> {
CoinInfo {
name: coin::get_name(&metadata),
symbol: coin::get_symbol(&metadata),
decimals: coin::get_decimals(&metadata),
name: metadata.get_name(),
symbol: metadata.get_symbol(),
decimals: metadata.get_decimals(),
remote_decimals,
metadata: option::some(metadata),
}
}
@@ -51,17 +56,25 @@ module its::coin_info {
self.decimals
}

public fun remote_decimals<T>(self: &CoinInfo<T>): u8 {
self.remote_decimals
}

public fun scaling<T>(self: &CoinInfo<T>): u256 {
utils::pow(10, self.remote_decimals - self.decimals)
}

public fun metadata<T>(self: &CoinInfo<T>): &Option<CoinMetadata<T>> {
&self.metadata
}

#[test_only]
public fun drop<T>(coin_info: CoinInfo<T>) {
let CoinInfo {name: _, symbol: _, decimals: _, metadata } = coin_info;
if (option::is_some(&metadata)) {
let CoinInfo {name: _, symbol: _, decimals: _, remote_decimals: _, metadata } = coin_info;
if (metadata.is_some()) {
abort 0
} else {
option::destroy_none(metadata)
metadata.destroy_none()
}
}
}
Loading

0 comments on commit c5e5322

Please sign in to comment.