Skip to content

Commit 3eed3b0

Browse files
authored
Merge pull request #15 from Tezsure/dev
2 parents 1ec9b77 + f540c9f commit 3eed3b0

29 files changed

+5277
-54
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
1+
# [2.1.0+1]
2+
3+
* Deploy contract
4+
* Call contract
5+
* Operation confirmation
6+
* Fix for revelation of an account Ref #12
7+
18
# [2.0.0]
29

310
* Dependencies update.
@@ -18,4 +25,4 @@ Initial version of library.
1825
* Generate keys from mnemonic.
1926
* Generate keys from mnemonics and passphrase.
2027
* Sign Operation Group.
21-
* Unlock fundraiser identity.
28+
* Unlock fundraiser identity.

README.md

Lines changed: 148 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,9 @@ Tezos is a decentralized blockchain that governs itself by establishing a true d
2222
* Unlock fundraiser identity.
2323
* Transfer Balance.
2424
* Delegate an Account.
25+
* Deploy a contract.
26+
* Call a contract.
27+
* Operation confirmation.
2528

2629
### Getting started
2730

@@ -154,6 +157,150 @@ print("Operation groupID ===> $result['operationGroupID']");
154157
155158
```
156159

160+
* Deploy a contract.
161+
* With this release we are excited to include the feature of trestles chain interactions, including contract deployment a user can directly write smart contracts in Michelson language and deploy it on Tezos chain using the `sendContractOriginationOperation()` method in return you'll get an origination id of the deployed contract that can be use to track the contract on chain. We have set an example for you below.
162+
163+
``` dart
164+
var server = '';
165+
166+
var contract = """parameter string;
167+
storage string;
168+
code { DUP;
169+
DIP { CDR ; NIL string ; SWAP ; CONS } ;
170+
CAR ; CONS ;
171+
CONCAT;
172+
NIL operation; PAIR}""";
173+
174+
var storage = '"Sample"';
175+
176+
var keyStore = KeyStoreModel(
177+
publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
178+
secretKey:
179+
'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
180+
publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
181+
);
182+
183+
var signer = await TezsterDart.createSigner(
184+
TezsterDart.writeKeyWithHint(keyStore.secretKey, 'edsk'));
185+
186+
var result = await TezsterDart.sendContractOriginationOperation(
187+
server,
188+
signer,
189+
keyStore,
190+
0,
191+
null,
192+
100000,
193+
1000,
194+
100000,
195+
contract,
196+
storage,
197+
codeFormat: TezosParameterFormat.Michelson,
198+
);
199+
200+
print("Operation groupID ===> $result['operationGroupID']");
201+
202+
```
203+
reference link: `https://github.com/Tezsure/Tezster_dart/blob/master/example/lib/main.dart#L110`
204+
<br>
205+
206+
* Call a contract.
207+
* We have also included the feature to call or invoke a deployed contract just use the inbuilt `sendContractInvocationOperation()` method in return you'll get an origination id of the invoked contract that can be used to track the contracts on chain. We have set an example for you below.
208+
209+
``` dart
210+
var server = '';
211+
212+
var keyStore = KeyStoreModel(
213+
publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
214+
secretKey:
215+
'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
216+
publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
217+
);
218+
219+
var signer = await TezsterDart.createSigner(
220+
TezsterDart.writeKeyWithHint(keyStore.secretKey, 'edsk'));
221+
222+
var contractAddress = 'KT1KA7DqFjShLC4CPtChPX8QtRYECUb99xMY';
223+
224+
var resultInvoke = await TezsterDart.sendContractInvocationOperation(
225+
server,
226+
signer,
227+
keyStore,
228+
contractAddress,
229+
10000,
230+
100000,
231+
1000,
232+
100000,
233+
'',
234+
'"Cryptonomicon"',
235+
codeFormat: TezosParameterFormat.Michelson);
236+
237+
print("Operation groupID ===> $result['operationGroupID']");
238+
239+
```
240+
reference link: `https://github.com/Tezsure/Tezster_dart/blob/master/example/lib/main.dart#L141`
241+
<br>
242+
243+
* Operation confirmation.
244+
* No wonder it's really important to await for confirmation for any on chain interactions. Hence, we have provided `awaitOperationConfirmation()` method with this release that developers can leverage for their advantage to confirm the originated contract's operations id. We have set an example for you how to use it.
245+
246+
``` dart
247+
var server = '';
248+
249+
var network = 'carthagenet';
250+
251+
var serverInfo = {
252+
'url': '',
253+
'apiKey': '',
254+
'network': network
255+
};
256+
257+
var contract = """parameter string;
258+
storage string;
259+
code { DUP;
260+
DIP { CDR ; NIL string ; SWAP ; CONS } ;
261+
CAR ; CONS ;
262+
CONCAT;
263+
NIL operation; PAIR}""";
264+
265+
var storage = '"Sample"';
266+
267+
var keyStore = KeyStoreModel(
268+
publicKey: 'edpkvQtuhdZQmjdjVfaY9Kf4hHfrRJYugaJErkCGvV3ER1S7XWsrrj',
269+
secretKey:
270+
'edskRgu8wHxjwayvnmpLDDijzD3VZDoAH7ZLqJWuG4zg7LbxmSWZWhtkSyM5Uby41rGfsBGk4iPKWHSDniFyCRv3j7YFCknyHH',
271+
publicKeyHash: 'tz1QSHaKpTFhgHLbqinyYRjxD5sLcbfbzhxy',
272+
);
273+
274+
var signer = await TezsterDart.createSigner(
275+
TezsterDart.writeKeyWithHint(keyStore.secretKey, 'edsk'));
276+
277+
var result = await TezsterDart.sendContractOriginationOperation(
278+
server,
279+
signer,
280+
keyStore,
281+
0,
282+
null,
283+
100000,
284+
1000,
285+
100000,
286+
contract,
287+
storage,
288+
codeFormat: TezosParameterFormat.Michelson,
289+
);
290+
291+
print("Operation groupID ===> $result['operationGroupID']");
292+
293+
var groupId = result['operationGroupID'];
294+
295+
var conseilResult = await TezsterDart.awaitOperationConfirmation(
296+
serverInfo, network, groupId, 5);
297+
298+
print('Originated contract at ${conseilResult['originated_contracts']}');
299+
300+
```
301+
reference link: `https://github.com/Tezsure/Tezster_dart/blob/master/example/lib/main.dart#L162`
302+
<br>
303+
157304
---
158305
**NOTE:**
159306
Use stable version of flutter to avoid package conflicts.
@@ -162,4 +309,4 @@ Use stable version of flutter to avoid package conflicts.
162309

163310
### Feature requests and bugs
164311

165-
Please file feature requests and bugs at the [issue tracker](https://github.com/Tezsure/tezster_dart/issues/new). If you want to contribute to this libary, please submit a Pull Request.
312+
Please file feature requests and bugs at the [issue tracker](https://github.com/Tezsure/tezster_dart/issues/new). If you want to contribute to this libary, please submit a Pull Request.

example/lib/main.dart

Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,91 @@ class _MyAppState extends State<MyApp> {
106106
);
107107
print("Applied operation ===> $delegationResult['appliedOp']");
108108
print("Operation groupID ===> $delegationResult['operationGroupID']");
109+
110+
//Deploy a contract
111+
var contract = """parameter string;
112+
storage string;
113+
code { DUP;
114+
DIP { CDR ; NIL string ; SWAP ; CONS } ;
115+
CAR ; CONS ;
116+
CONCAT;
117+
NIL operation; PAIR}""";
118+
119+
var storage = '"Sample"';
120+
var contractOriginationSigner = await TezsterDart.createSigner(
121+
TezsterDart.writeKeyWithHint(keyStore.secretKey, 'edsk'));
122+
123+
var resultContractOrigination =
124+
await TezsterDart.sendContractOriginationOperation(
125+
server,
126+
contractOriginationSigner,
127+
keyStore,
128+
0,
129+
null,
130+
100000,
131+
1000,
132+
100000,
133+
contract,
134+
storage,
135+
codeFormat: TezosParameterFormat.Michelson,
136+
);
137+
138+
print(
139+
"Operation groupID ===> $resultContractOrigination['operationGroupID']");
140+
141+
//Call a contract
142+
var contractInvocationSigner = await TezsterDart.createSigner(
143+
TezsterDart.writeKeyWithHint(keyStore.secretKey, 'edsk'));
144+
145+
var contractAddress = 'KT1KA7DqFjShLC4CPtChPX8QtRYECUb99xMY';
146+
147+
var resultInvoke = await TezsterDart.sendContractInvocationOperation(
148+
server,
149+
contractInvocationSigner,
150+
keyStore,
151+
contractAddress,
152+
10000,
153+
100000,
154+
1000,
155+
100000,
156+
'',
157+
'"Cryptonomicon"',
158+
codeFormat: TezosParameterFormat.Michelson);
159+
160+
print("Operation groupID ===> $resultInvoke['operationGroupID']");
161+
162+
//Await opration Confirmation
163+
var network = 'carthagenet';
164+
165+
var serverInfo = {'url': '', 'apiKey': '', 'network': network};
166+
167+
var operationConfirmationSigner = await TezsterDart.createSigner(
168+
TezsterDart.writeKeyWithHint(keyStore.secretKey, 'edsk'));
169+
170+
var resultoperationConfirmation =
171+
await TezsterDart.sendContractOriginationOperation(
172+
server,
173+
operationConfirmationSigner,
174+
keyStore,
175+
0,
176+
null,
177+
100000,
178+
1000,
179+
100000,
180+
contract,
181+
storage,
182+
codeFormat: TezosParameterFormat.Michelson,
183+
);
184+
185+
print(
186+
"Operation groupID ===> $resultoperationConfirmation['operationGroupID']");
187+
188+
var groupId = resultoperationConfirmation['operationGroupID'];
189+
190+
var conseilResult = await TezsterDart.awaitOperationConfirmation(
191+
serverInfo, network, groupId, 5);
192+
193+
print('Originated contract at ${conseilResult['originated_contracts']}');
109194
}
110195

111196
@override

example/pubspec.lock

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ packages:
1414
name: bip39
1515
url: "https://pub.dartlang.org"
1616
source: hosted
17-
version: "1.0.3"
17+
version: "1.0.4"
1818
blake2b:
1919
dependency: transitive
2020
description:
@@ -117,7 +117,7 @@ packages:
117117
name: flutter_sodium
118118
url: "https://pub.dartlang.org"
119119
source: hosted
120-
version: "0.1.9"
120+
version: "0.1.11"
121121
flutter_test:
122122
dependency: "direct dev"
123123
description: flutter
@@ -164,7 +164,7 @@ packages:
164164
name: pointycastle
165165
url: "https://pub.dartlang.org"
166166
source: hosted
167-
version: "1.0.2"
167+
version: "2.0.1"
168168
sky_engine:
169169
dependency: transitive
170170
description: flutter
@@ -218,7 +218,7 @@ packages:
218218
path: ".."
219219
relative: true
220220
source: path
221-
version: "2.0.0"
221+
version: "2.1.0+1"
222222
typed_data:
223223
dependency: transitive
224224
description:
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2+
import 'package:tezster_dart/michelson_parser/michelson_parser.dart';
3+
4+
class TezosLanguageUtil {
5+
static String translateMichelsonToMicheline(String code) {
6+
var result = MichelsonParser.parseMichelson(code);
7+
return result;
8+
}
9+
10+
static String translateMichelineToHex(p) {
11+
return MichelsonParser.translateMichelineToHex(p);
12+
}
13+
}

0 commit comments

Comments
 (0)