-
Notifications
You must be signed in to change notification settings - Fork 13
140 lines (130 loc) · 4.47 KB
/
suins-combine-execute.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
---
name: SuiNS - Combine and Execute Multi-Sig TX
on:
workflow_dispatch:
inputs:
rpc:
description: 'RPC for sui client'
required: true
default: 'https://rpc.mainnet.sui.io:443'
type: string
sui_tools_image:
description: 'image reference of sui_tools'
default: 'mysten/sui-tools:mainnet'
required: true
type: string
all_pks:
description: 'ordered pubkeys (separate by spaces)'
required: true
type: string
default: 'AD+3mg5J5olToTEYrcxJ6DaVxUCWCBYOgI9dADaSlh/D AOSeqn1vaDsfKyErF5Oe2z6X0yD25HytzYxIN0sM9cSX AJdLYYKG/CTI9yFl68meoO8gHKUcTLpip6AYRXsS0H3g ANSiX5Dt4GGMydZKGlUdhbvJbJq/A4G5CwotC3h3LImf AKvhJE5Kuto6KRqWaD8vtPJ7u2glSdZTfK5AWnFQ5jhu AIsWkAJaleXuv6gq9Vtyxfigpr/9RqzRYCyB0pz8AWYS'
all_sigs:
description: 'All ordered signatures (separate by spaces)'
required: true
type: string
default: ''
weights:
description: 'weights for each key'
required: true
default: '1 1 1 1 1 1'
type: string
threshold:
description: 'multisig account threshold'
required: true
default: '3'
type: string
test_data_only:
description: 'Just a test for data output from artifacts'
required: true
default: false
type: boolean
execute_tx:
description: 'execute combined musig tx'
required: true
default: false
type: boolean
jobs:
suins_combine_and_execute:
name: Suins Combine and Execute tx
runs-on: ubuntu-latest
steps:
- name: Create client.yaml and keystore
working-directory: .
env:
NETWORK: mainnet
RPC: ${{ inputs.rpc }}
run: |
mkdir sui_config
touch sui_config/sui.keystore
cat <<EOF > sui_config/sui.keystore
[
"AJJqjgjU5B9vG2xV2c5kd51eyLYJ0yuEcSYRjzCKIQhT"
]
EOF
cat <<EOF > sui_config/client.yaml
---
keystore:
File: $HOME/.sui/sui_config/sui.keystore
envs:
- alias: $NETWORK
rpc: "$RPC"
ws: ~
EOF
mkdir $HOME/.sui
cp -r sui_config $HOME/.sui/sui_config
- name: Set up sui environment
working-directory: .
run: |
docker pull docker.io/${{ inputs.sui_tools_image }}
docker create --name tmp_cont docker.io/${{ inputs.sui_tools_image }}
docker cp tmp_cont:/usr/local/bin/sui sui
./sui client addresses
./sui client switch --address 0x2ffe93910ae4bc68eccc5418b748abcfc417d6a94c4e3e8414cdea92b20e8768
- name: Install JQ
working-directory: .
run: |
sudo apt update -y && sudo apt install -y jq
- name: Download artifact
id: download-artifact
uses: dawidd6/action-download-artifact@v2
with:
workflow: suins-build-tx.yaml
workflow_conclusion: success
name: transaction-data
path: scripts/tx
- name: Transaction Data being executed
run: |
cat scripts/tx/tx-data.txt
- name: Combine tx
if: ${{ !inputs.test_data_only }}
run: |
set -x
ALL_PKS="${{ inputs.all_pks }}"
ALL_SIGS="${{ inputs.all_sigs }}"
echo "debug"
echo $ALL_PKS
echo $ALL_SIGS
combined_musig="$(./sui keytool multi-sig-combine-partial-sig \
--pks $(echo $ALL_PKS) \
--weights $(echo ${{ inputs.weights }}) \
--threshold $(echo ${{ inputs.threshold }}) \
--sigs $(echo $ALL_SIGS) --json | jq .multisigSerialized | tr -d \" )"
echo $ALL_PKS > scripts/tx/pks.txt
echo $ALL_SIGS > scripts/tx/sigs.txt
echo $combined_musig > scripts/tx/combined_musig.txt
- name: execute signed tx
if: ${{ !inputs.test_data_only && inputs.execute_tx }}
run: |
set -x
echo "combined musig"
echo "$(cat scripts/tx/combined_musig.txt)"
result="$(./sui client execute-signed-tx \
--tx-bytes $(cat scripts/tx/tx-data.txt) \
--signatures $(cat scripts/tx/combined_musig.txt))"
echo $result > scripts/tx/result.txt
cat scripts/tx/result.txt
- name: Upload Transaction Artifact
uses: actions/upload-artifact@v3
with:
name: combine-and-execute-transaction
path: scripts/tx