Skip to content
Permalink
Browse files

update

  • Loading branch information...
pvl1175 committed Jun 18, 2019
1 parent 406e1ff commit 477bb32b980f29f852cbd56d0bd97b459b786bc4
@@ -1,15 +1,15 @@
<Project Sdk="Microsoft.NET.Sdk">

<Project Sdk="Microsoft.NET.Sdk" ToolsVersion="15.0">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.2</TargetFramework>
<FileUpgradeFlags>40</FileUpgradeFlags>
<UpgradeBackupLocation>D:\Dev\GitHub\Examples\API\CreditsCSharpDemo\Backup\</UpgradeBackupLocation>
<OldToolsVersion>2.0</OldToolsVersion>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="apache-thrift-netcore" Version="0.9.3.2" />
<PackageReference Include="Chaos.NaCl.Core" Version="1.0.0" />
<PackageReference Include="SauceControl.Blake2Fast" Version="0.2.0" />
<PackageReference Include="SimpleBase" Version="1.8.0" />
</ItemGroup>

</Project>
</Project>
@@ -112,6 +112,13 @@ private Transaction CreateTransactionWithSmartContract(string smCode)
return null;
}

transaction.SmartContract = new SmartContractInvocation();
transaction.SmartContract.SmartContractDeploy = new SmartContractDeploy()
{
ByteCodeObjects = byteCode.ByteCodeObjects,
SourceCode = smCode
};

transaction.Target = SauceControl.Blake2Fast.Blake2s.ComputeHash(target.ToArray());

var bytes = new byte[86];
@@ -1,8 +1,7 @@
{
"profiles": {
"CreditsCSAPIDemo": {
"commandName": "Project",
"commandLineArgs": "127.0.0.1 35SR5JC6DA9pPd9xYQ7oRvvCgJKK7teLoMwDMBmEN45Q tvkphPU2Y6svC38FaWuer8zF2F7DsfNkqMsko76uL8Rdv5oztCqmcEwKWi5NbDgtsy7QDNe9vXhkHFQTATNFksc DXEiDtU7NHz8YdQEzugBXh3oqaVQ6nGHMkFPwLtnvZSG"
"commandName": "Project"
}
}
}
@@ -3,6 +3,7 @@ rmdir /S /Q thrift-interface-definitions
rmdir /S /Q obj
rmdir /S /Q NodeApi
del Annotation.cs
del Amount.cs
del APIResponse.cs
del ByteCodeObject.cs
del MethodArgument.cs
@@ -4,6 +4,7 @@ rm -r -f obj
rm -r -f NodeApi

rm Annotation.cs
rm Amount.cs
rm APIResponse.cs
rm ByteCodeObject.cs
rm MethodArgument.cs
@@ -1 +1,2 @@
dotnet run
pause
@@ -110,6 +110,66 @@ class CreditsUtils {
PerStr = this.concatTypedArrays(PerStr, this.numbToByte(tran.fee.commission, 2));
PerStr = this.concatTypedArrays(PerStr, new Uint8Array([1]));
PerStr = this.concatTypedArrays(PerStr, new Uint8Array(1));

let UserField = new Uint8Array();
tran.smartContract = new SmartContractInvocation();
UserField = this.concatTypedArrays(UserField, new Uint8Array([11, 0, 1]));
UserField = this.concatTypedArrays(UserField, new Uint8Array(4));

UserField = this.concatTypedArrays(UserField, new Uint8Array([15, 0, 2, 12]));
UserField = this.concatTypedArrays(UserField, new Uint8Array(4));

UserField = this.concatTypedArrays(UserField, new Uint8Array([15, 0, 3, 11, 0, 0, 0, 0]));

tran.smartContract.forgetNewState = false;
UserField = this.concatTypedArrays(UserField, new Uint8Array([2, 0, 4, 0]));

if (smCode !== undefined) {
UserField = this.concatTypedArrays(UserField, new Uint8Array([12, 0, 5, 11, 0, 1]));

tran.smartContract.smartContractDeploy = new SmartContractDeploy({
sourceCode: smCode
});

UserField = this.concatTypedArrays(UserField, this.numbToByte(smCode.length, 4).reverse());
UserField = this.concatTypedArrays(UserField, this.convertCharToByte(smCode));

UserField = this.concatTypedArrays(UserField, new Uint8Array([15, 0, 2, 12]));
let ByteCode = this.client().SmartContractCompile(smCode);

if (ByteCode.status.code === 0) {
tran.smartContract.smartContractDeploy.byteCodeObjects = [];
UserField = this.concatTypedArrays(UserField, this.numbToByte(ByteCode.byteCodeObjects.length, 4).reverse());

for (let i in ByteCode.byteCodeObjects) {

let val = ByteCode.byteCodeObjects[i];
UserField = this.concatTypedArrays(UserField, new Uint8Array([11, 0, 1]));
UserField = this.concatTypedArrays(UserField, this.numbToByte(val.name.length, 4).reverse());
UserField = this.concatTypedArrays(UserField, this.convertCharToByte(val.name));

UserField = this.concatTypedArrays(UserField, new Uint8Array([11, 0, 2]));
UserField = this.concatTypedArrays(UserField, this.numbToByte(val.byteCode.length, 4).reverse());
UserField = this.concatTypedArrays(UserField, this.convertCharToByte(val.byteCode));
tran.smartContract.smartContractDeploy.byteCodeObjects.push(new ByteCodeObject({
name: val.name,
byteCode: val.byteCode
}));
UserField = this.concatTypedArrays(UserField, new Uint8Array(1));
}
}
else {
ResObj.Message = ByteCode.Status.Message;
return ResObj;
}

UserField = this.concatTypedArrays(UserField, new Uint8Array([11, 0, 3, 0, 0, 0, 0, 8, 0, 4, 0, 0, 0, 0, 0]));
}

UserField = this.concatTypedArrays(UserField, new Uint8Array(1));
PerStr = this.concatTypedArrays(PerStr, this.numbToByte(UserField.length, 4));
PerStr = this.concatTypedArrays(PerStr, UserField);

tran.signature = nacl.sign.detached(PerStr, this.privateKeyByte);
return tran;
}
@@ -17,9 +17,9 @@
<script>
function run()
{
var pubkey = "your public key";
var prvkey = "your private key";
var trgKey = "your target key";
var pubkey = "35SR5JC6DA9pPd9xYQ7oRvvCgJKK7teLoMwDMBmEN45Q"; //"your public key";
var prvkey = "tvkphPU2Y6svC38FaWuer8zF2F7DsfNkqMsko76uL8Rdv5oztCqmcEwKWi5NbDgtsy7QDNe9vXhkHFQTATNFksc";
var trgKey = "DXEiDtU7NHz8YdQEzugBXh3oqaVQ6nGHMkFPwLtnvZSG"; //"your target key";
var url = "http://127.0.0.1:8081";
var client = new CreditsUtils(pubkey, prvkey, trgKey, url);
@@ -4,5 +4,5 @@
Using Credits (version 4_2_410) in Docker

## credits_docker_testnet
Using Credits (version 4.2.412.3) in Docker
Using Credits (version 4.2.417) in Docker

0 comments on commit 477bb32

Please sign in to comment.
You can’t perform that action at this time.