Repository: ecadlabs/taquito (ts)

Issue:
Schema.ExtractSchema() returns "list"
**Description**

The method [`ExtractSchema()` of `Schema`](https://tezostaquito.io/docs/michelson_encoder/#the-extractschema-method) returns string `"list"` for a complex Michelson starting with a `{ prim: 'list' }`. Or am I wrong and this is an expected exception?

**Steps To Reproduce**
Steps to reproduce the behavior:
1. Run following code.
    ```typescript
    const storageType = {
        prim: 'list',
        args: [
            {
                prim: 'pair',
                args: [
                    { prim: 'address', annots: ['%from'] },
                    { prim: 'address', annots: ['%to'] },
                ],
            },
        ],
    };
    const storageSchema = new Schema(storageType);
    const extractSchema = storageSchema.ExtractSchema();
    println(JSON.stringify(extractSchema, null, 2));
    ```
2. It prints (returns) string `"list"`.

**Expected behavior**
Expected to return complex object like:
```typescript
[
    {
        "from": "address",
        "to": "address"
    }
]
```


Pull request description:
Issue-960 Changes for ExtractSchema for token type list
Resolves #960 

Patch:
diff --git a/packages/taquito-beacon-wallet/src/version.ts b/packages/taquito-beacon-wallet/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-beacon-wallet/src/version.ts
+++ b/packages/taquito-beacon-wallet/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-http-utils/src/version.ts b/packages/taquito-http-utils/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-http-utils/src/version.ts
+++ b/packages/taquito-http-utils/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-ledger-signer/src/version.ts b/packages/taquito-ledger-signer/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-ledger-signer/src/version.ts
+++ b/packages/taquito-ledger-signer/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-local-forging/src/version.ts b/packages/taquito-local-forging/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-local-forging/src/version.ts
+++ b/packages/taquito-local-forging/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-michel-codec/src/version.ts b/packages/taquito-michel-codec/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-michel-codec/src/version.ts
+++ b/packages/taquito-michel-codec/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-michelson-encoder/src/tokens/list.ts b/packages/taquito-michelson-encoder/src/tokens/list.ts
index 5804008a2..cdffef7bb 100644
--- a/packages/taquito-michelson-encoder/src/tokens/list.ts
+++ b/packages/taquito-michelson-encoder/src/tokens/list.ts
@@ -67,6 +67,9 @@ export class ListToken extends Token {
   }
 
   public ExtractSchema() {
-    return ListToken.prim;
+    const valueSchema = this.createToken(this.val.args[0], this.idx);
+    return {
+      [ListToken.prim] : valueSchema.ExtractSchema()
+    }
   }
 }
diff --git a/packages/taquito-michelson-encoder/src/version.ts b/packages/taquito-michelson-encoder/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-michelson-encoder/src/version.ts
+++ b/packages/taquito-michelson-encoder/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-remote-signer/src/version.ts b/packages/taquito-remote-signer/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-remote-signer/src/version.ts
+++ b/packages/taquito-remote-signer/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-rpc/src/version.ts b/packages/taquito-rpc/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-rpc/src/version.ts
+++ b/packages/taquito-rpc/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-signer/src/version.ts b/packages/taquito-signer/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-signer/src/version.ts
+++ b/packages/taquito-signer/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-tezbridge-signer/src/version.ts b/packages/taquito-tezbridge-signer/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-tezbridge-signer/src/version.ts
+++ b/packages/taquito-tezbridge-signer/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-tezbridge-wallet/src/version.ts b/packages/taquito-tezbridge-wallet/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-tezbridge-wallet/src/version.ts
+++ b/packages/taquito-tezbridge-wallet/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-tzip12/src/version.ts b/packages/taquito-tzip12/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-tzip12/src/version.ts
+++ b/packages/taquito-tzip12/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-tzip16/src/version.ts b/packages/taquito-tzip16/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-tzip16/src/version.ts
+++ b/packages/taquito-tzip16/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito-utils/src/version.ts b/packages/taquito-utils/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito-utils/src/version.ts
+++ b/packages/taquito-utils/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */
diff --git a/packages/taquito/src/version.ts b/packages/taquito/src/version.ts
index c4402c59b..c27a5d4ab 100644
--- a/packages/taquito/src/version.ts
+++ b/packages/taquito/src/version.ts
@@ -2,7 +2,7 @@
 // IMPORTANT: THIS FILE IS AUTO GENERATED! DO NOT MANUALLY EDIT OR CHECKIN!
 /* tslint:disable */
 export const VERSION = {
-    "commitHash": "061791d2b7187924d7460370e9b52e7172267d7b",
+    "commitHash": "60c52234aa0508f5025d978fb07f6e6b35ac951f",
     "version": "9.2.0"
 };
 /* tslint:enable */


Test patch:
diff --git a/packages/taquito-michelson-encoder/test/manager.spec.ts b/packages/taquito-michelson-encoder/test/manager.spec.ts
index f8b6304ee..b93d96945 100644
--- a/packages/taquito-michelson-encoder/test/manager.spec.ts
+++ b/packages/taquito-michelson-encoder/test/manager.spec.ts
@@ -18,7 +18,7 @@ describe('Schema test', () => {
   it('Should extract signature properly', () => {
     const schema = new ParameterSchema(doSchema);
     expect(schema.ExtractSignatures()).toContainEqual([
-      { lambda: { parameters: 'unit', returns: 'list' } },
+      { lambda: { parameters: 'unit', returns: {list: "operation"} } },
     ]);
   });
 
diff --git a/packages/taquito-michelson-encoder/test/proto005/multisig.spec.ts b/packages/taquito-michelson-encoder/test/proto005/multisig.spec.ts
index 4a197da0c..fa0b28868 100644
--- a/packages/taquito-michelson-encoder/test/proto005/multisig.spec.ts
+++ b/packages/taquito-michelson-encoder/test/proto005/multisig.spec.ts
@@ -56,19 +56,24 @@ describe('Contract with or token inside a pair token', () => {
     const schema = new ParameterSchema(genericMultisig[0].args[0] as any);
     expect(schema.ExtractSignatures()).toContainEqual(['default', 'unit']);
     expect(schema.ExtractSignatures()).toContainEqual([
-      'main',
-      'nat',
-      'operation',
-      { lambda: { parameters: 'unit', returns: 'list' } },
-      'list',
-    ]);
+        "main", 
+        "nat", 
+        "operation", 
+        {
+          "lambda": {
+                      "parameters": "unit", 
+                      "returns": {list: "operation"}
+                    }
+        }, 
+        {list: "signature"}
+      ]);
     expect(schema.ExtractSignatures()).toContainEqual([
       'main',
       'nat',
       'change_keys',
       'nat',
-      'list',
-      'list',
+      {list: "key"},
+      {list: "signature"}
     ]);
   });
 });
diff --git a/packages/taquito-michelson-encoder/test/sample1.spec.ts b/packages/taquito-michelson-encoder/test/sample1.spec.ts
index c891eee0d..21204d7f8 100644
--- a/packages/taquito-michelson-encoder/test/sample1.spec.ts
+++ b/packages/taquito-michelson-encoder/test/sample1.spec.ts
@@ -164,7 +164,12 @@ describe('Schema test', () => {
         '5': 'address',
         '6': 'nat',
       },
-      createAccounts: 'list',
+      createAccounts:  {
+        list: {
+          "6": "address",
+          "7": "nat",
+        },
+      },
       transfer: {
         '0': 'address',
         '1': 'nat',
@@ -180,12 +185,17 @@ describe('Schema test', () => {
   it('Should extract signature properly', () => {
     const schema = new ParameterSchema(params);
     const sig = schema.ExtractSignatures();
-
     expect(sig).toContainEqual(['allowance', 'address', 'address', 'contract']);
     expect(sig).toContainEqual(['approve', 'address', 'nat']);
     expect(sig).toContainEqual(['balanceOf', 'address', 'contract']);
     expect(sig).toContainEqual(['createAccount', 'address', 'nat']);
-    expect(sig).toContainEqual(['createAccounts', 'list']);
+    expect(sig).toContainEqual(["createAccounts", {
+                                                      list: {
+                                                                "6": "address", 
+                                                                "7": "nat"
+                                                               }
+                                                    }
+                              ]);
     expect(sig).toContainEqual(['transfer', 'address', 'nat']);
     expect(sig).toContainEqual(['transferFrom', 'address', 'address', 'nat']);
   });
diff --git a/packages/taquito-michelson-encoder/test/sample10.spec.ts b/packages/taquito-michelson-encoder/test/sample10.spec.ts
index b7cef155f..3de32870b 100644
--- a/packages/taquito-michelson-encoder/test/sample10.spec.ts
+++ b/packages/taquito-michelson-encoder/test/sample10.spec.ts
@@ -78,12 +78,10 @@ describe('Schema test', () => {
     );
     expect(schema.isMultipleEntryPoint).toBeTruthy();
 
-    expect(schema.ExtractSignatures()).toContainEqual([
-      'transfer',
-      'list',
-      'key_hash',
-      'key',
-      'signature',
-    ]);
+    expect(schema.ExtractSignatures()).toContainEqual(["transfer", 
+        {list: {"amount": "mutez", "beneficiary": "contract"}}, 
+        "key_hash", 
+        "key", 
+        "signature"]);
   });
 });
diff --git a/packages/taquito-michelson-encoder/test/sample21.spec.ts b/packages/taquito-michelson-encoder/test/sample21.spec.ts
new file mode 100644
index 000000000..3930ca007
--- /dev/null
+++ b/packages/taquito-michelson-encoder/test/sample21.spec.ts
@@ -0,0 +1,27 @@
+import { Schema } from '../src/schema/storage';
+
+describe('List token type structure', () => {
+  it('Should extract correct schema for token type list', () => {
+    const storageType = {
+        prim: 'list',
+        args: [
+            {
+                prim: 'pair',
+                args: [
+                    { prim: 'address', annots: ['%from'] },
+                    { prim: 'address', annots: ['%to'] },
+                ],
+            },
+        ],
+    };
+    const schema = new Schema(storageType);
+
+    expect(schema.ExtractSchema()).toEqual({
+        list: {
+        "from": "address",
+        "to": "address"
+      }
+    });
+
+  });
+});
\ No newline at end of file
diff --git a/packages/taquito-michelson-encoder/test/sample6.spec.ts b/packages/taquito-michelson-encoder/test/sample6.spec.ts
index c6ca8cce6..d4b432cb2 100644
--- a/packages/taquito-michelson-encoder/test/sample6.spec.ts
+++ b/packages/taquito-michelson-encoder/test/sample6.spec.ts
@@ -12,8 +12,15 @@ describe('Schema test', () => {
     const schema = new Schema(storage6);
     expect(schema.ExtractSchema()).toEqual({
       key_info: {
-        key_groups: 'list',
-        overall_threshold: 'nat',
+        key_groups: {
+          list:  {
+            "group_threshold": "nat",
+            "signatories":  {
+              list: "key",
+            },
+          },
+        },
+        "overall_threshold": "nat",
       },
       pour_info: {
         pour_authorizer: 'key',
@@ -135,7 +142,14 @@ describe('Schema test', () => {
         action_input: {
           Set_delegate: 'key_hash',
           Set_keys: {
-            key_groups: 'list',
+            key_groups: {
+              list:  {
+                "group_threshold": "nat",
+                "signatories":  {
+                  list: "key",
+                },
+              },
+            },
             overall_threshold: 'nat',
           },
           Set_pour: {
@@ -147,13 +161,17 @@ describe('Schema test', () => {
             transfer_amount: 'mutez',
           },
         },
-        signatures: 'list',
+        signatures: {
+           list: {
+             list: "signature",
+           },
+         },
       },
     });
 
     const signatures = schema.ExtractSignatures();
     expect(signatures).toContainEqual(['Pour', 'signature', 'mutez']);
-    expect(signatures).toContainEqual(['Action', 'Set_delegate', 'key_hash', 'list']);
+    expect(signatures).toContainEqual(['Action', 'Set_delegate', 'key_hash', {"list": {"list": "signature"}}]);
   });
 
   it('Should encode parameter properly', () => {
diff --git a/packages/taquito-michelson-encoder/test/tokens/lambda.spec.ts b/packages/taquito-michelson-encoder/test/tokens/lambda.spec.ts
index afa923abf..34a121bc4 100644
--- a/packages/taquito-michelson-encoder/test/tokens/lambda.spec.ts
+++ b/packages/taquito-michelson-encoder/test/tokens/lambda.spec.ts
@@ -25,7 +25,9 @@ describe('Lambda token', () => {
         expect(result).toEqual({
             lambda: {
                 parameters: 'unit',
-                returns: 'list'
+                returns: {
+                            list: "operation",
+                         }
             }
         });
     });